首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

URL重写有关问题,大家帮忙

2012-01-10 
URL重写问题,大家帮忙在webconfig里我是这样配置的?xml version1.0?!--Note: As an alternative to

URL重写问题,大家帮忙
在webconfig里我是这样配置的
<?xml version="1.0"?>
<!-- 
  Note: As an alternative to hand editing this file you can use the 
  web admin tool to configure settings for your application. Use
  the Website->Asp.Net Configuration option in Visual Studio.
  A full list of settings and comments can be found in 
  machine.config.comments usually located in 
  \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
  <configSections>
  <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
  </configSections>
  <RewriterConfig>
  <Rules>
  <!-- Rules for Blog Content Displayer -->

  <RewriterRule>
  <LookFor> ~/modify/(.[0-9]*)\.aspx </LookFor>
  <SendTo> ~/modify/modifyOrders.aspx?ORDERS_ID=$1 </SendTo>
  </RewriterRule>
  </Rules>
  </RewriterConfig>
<system.web>
<!-- 
  Set compilation debug="true" to insert debugging 
  symbols into the compiled page. Because this 
  affects performance, set this value to true only 
  during development.
  -->
<compilation debug="true"/>
<!--
  The <authentication> section enables configuration 
  of the security authentication mode used by 
  ASP.NET to identify an incoming user. 
  -->
<authentication mode="Forms"/>
<!--
  The <customErrors> section enables configuration 
  of what to do if/when an unhandled error occurs 
  during the execution of a request. Specifically, 
  it enables developers to configure html error pages 
  to be displayed in place of a error stack trace.

  <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
  <error statusCode="403" redirect="NoAccess.htm" />
  <error statusCode="404" redirect="FileNotFound.htm" />
  </customErrors>
  -->
  <globalization 
  requestEncoding="utf-8" 
  responseEncoding="utf-8" 
  />
  <httpHandlers>
  <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
  </httpHandlers>
  </system.web>

  <appSettings>
  <add key="SQLConnection" value="uid=sa;pwd=sa;server=127.0.0.1;database=CpmmUserDB"/>
  <add key="Service.WebMethod" value="http://localhost/CPMM_LEVEL2/WebMethod.asmx"/>
  </appSettings>
</configuration>
然后在搜索页面上,我是这样写的
<a href=\"../modify/"+dsORDER_INFO.Tables[0].Rows[i][0]+".aspx\">修</a>

最后我浏览页面点修,但页面不会URL重写,请大家帮忙!!


[解决办法]
帮顶
[解决办法]
最后我浏览页面点修,但页面不会URL重写,请大家帮忙!! 
??

应该浏览器地址中显示"../modify/"+dsORDER_INFO.Tables[0].Rows[i][0]+".aspx


而实际页面为~/modify/modifyOrders.aspx?ORDERS_ID=$1吧





[解决办法]
再帮顶
[解决办法]
~/modify/(.[0-9]*)\.aspx

只能完全字符替换吧,不能用正则表达式

这个url重写太弱,没多大作用
[解决办法]
dsORDER_INFO.Tables[0].Rows[i][0]取出来的是数字吗?符合你的正则吗?
[解决办法]
最后我浏览页面点修,但页面不会URL重写,请大家帮忙!! 

--------------
问题说的不是很清楚,重写就是你访问~/modify/(.[0-9]*)\.aspx ,会显示 ~/modify/modifyOrders.aspx?ORDERS_ID=$1页的内容,而不是你访问后者转向到后者。
[解决办法]
不好意思,我搞错了,我用过的是

<urlMappings>
<add url="~/modify/1.aspx " mappedUrl="~/modify/modifyOrders.aspx?ORDERS_ID=$1 
" />
<add url="~/modify/1.aspx " mappedUrl="~/modify/modifyOrders.aspx?ORDERS_ID=$2 
" />
</urlMappings>
功能太差
[解决办法]
应该可能还是iis或者web.config配置的问题

热点排行