利用URLRewriting.dll实现asp.net页面伪静态!(不用安装Rewriter)

本文介绍了一种在ASP.NET应用中实现URL重写的配置方法,通过修改web.config文件并使用URLRewriting.NET库来实现友好的URL格式。文章详细展示了如何配置重写规则将旧的URL映射到新的ASP.NET页面。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

configuration>                       
 <configSections>           
  <!-- The <configSections> element must contain a <section> tag for the <RewriterConfig> section element.
    The type of the section handler is RewriterConfigSerializerSectionHandler, which is responsible for
      deserializing the <RewriterConfig> section element into a RewriterConfig instance... -->
  <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
 </configSections>     
 <RewriterConfig>               
  <Rules>     
   
   <RewriterRule>
    <LookFor>~/index.html</LookFor>
    <SendTo><![CDATA[~/index.aspx]]></SendTo>
   </RewriterRule>
   <RewriterRule>
    <LookFor>~/blog/Article/(\d+).html</LookFor>
    <SendTo><![CDATA[~/blog/Article/ArticleView.aspx?id=$1]]></SendTo>
   </RewriterRule>
   <RewriterRule>
    <LookFor>~/blog/Pic/(\d+).html</LookFor>
    <SendTo><![CDATA[~/blog/Pic/PicView.aspx?id=$1]]></SendTo>
   </RewriterRule>
   
   <RewriterRule>
    <LookFor>~/Album/(\d+).html</LookFor>
    <SendTo><![CDATA[~/Album/Html/list_$1.html]]></SendTo>
   </RewriterRule>
   
   <RewriterRule>
    <LookFor>~/Search/Search.html</LookFor>
    <SendTo><![CDATA[~/Search/Search.aspx]]></SendTo>
   </RewriterRule>-->
   
   <!-- Reg
   <RewriterRule>
    <LookFor>~/Member/RegisterTerm.html</LookFor>
    <SendTo><![CDATA[~/Member/RegisterTerm.aspx]]></SendTo>
   </RewriterRule>
   <RewriterRule>
    <LookFor>~/Member/RegisterAccount.html</LookFor>
    <SendTo><![CDATA[~/Member/RegisterAccount.aspx]]></SendTo>
   </RewriterRule>-->
   
   <!-- Meet
   <RewriterRule>
    <LookFor>~/Meet/index.html</LookFor>
    <SendTo><![CDATA[~/Meet/index.aspx]]></SendTo>
   </RewriterRule>-->
   
   <!-- Good
   <RewriterRule>
    <LookFor>~/Good/index.html</LookFor>
    <SendTo><![CDATA[~/Good/index.aspx]]></SendTo>
   </RewriterRule>-->
  </Rules>
 </RewriterConfig>
 <system.web>
  <!--Ajax-->
  <httpHandlers>
   <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro" />
  </httpHandlers>
  <httpModules>
   <!-- 地址改写 -->
   <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
   

 

1     以上内容写到web.config里面   然后URLRewriting.dll文件放到bin目录里面  

2.  然后iis配置里面添加一个html的拓展名,文件指向.net的文件 ,就是和asp.net的拓展名的文件一样

 

 

 

这样就完成url重写 ,就不需要安装isapi rewrite那么麻烦了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值