url重写 试用后总结

1:下载UrlWriter

2:安装下载的UrlWriter---安装后会默认打开一个文件夹(C:\Users\Administrator\Documents\MSDN\URL Rewriting in ASP.NET\URLRewriter\bin\Debug)

3:只要在步骤2中的文件夹找到URLRewriter.dll 拷到你项目对应的bin 目录或其他目录    然后在你的程序里去把这个引用添加进去

4:配置配置文件只要按如下的红色字体配置到对应的位置即可

   需要注意的:

1:    是最后一段红色字,可以直接手动这样加在配置文件里    那么iis 里就不需要再去配置映射了 (如果去掉最后一段红色字体 那么就要在iis 找到你的项目 --功能视图-处理程序映射-右击添加脚本映射。如果你的服务器是64位就添加64位的dll  如果是32位就要添加32位的dll  如果是64位 应用程序池又启用了32位那么32位 和42位都要添加

       请求路径是 :*.html  

      可执行文件路径32位:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll

      可执行文件路径64位: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll

      名称自几定义即可定义 

2:  <add  name="URLRewriter" verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />  这个在应用程序池 经典模式下加在  </system.web>里

如果是在集成模式下放在    <system.webServer>   <handlers>  里 即配置文件最后一段红色字体里




<?xml version="1.0" encoding="UTF-8"?>
<!--
  有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler,URLRewriter" />
    <sectionGroup name="SinaSectionGroup">
      <section name="SinaSection" type="System.Configuration.NameValueSectionHandler" />
    </sectionGroup>
  </configSections>
  <RewriterConfig>
    <Rules>
      <RewriterRule>
        <LookFor>~/index\.html?</LookFor>
        <SendTo>~/index.aspx</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>~/menshoes\.html?</LookFor>
        <SendTo>~/menshoes.aspx</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>~/womenshoe\.html?</LookFor>
        <SendTo>~/womenshoe.aspx</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>~/jifen\.html?</LookFor>
        <SendTo>~/jifen.aspx</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>~/salezone\.html?</LookFor>
        <SendTo>~/salezone.aspx</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>~/style\.html?</LookFor>
        <SendTo>~/style.aspx</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>~/Show\.html?</LookFor>
        <SendTo>~/Show.aspx</SendTo>
      </RewriterRule>
    </Rules>
  </RewriterConfig>

  <system.web>
    <sessionState mode="InProc" cookieless="false" timeout="120" />
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
    <compilation targetFramework="4.0">

      <!-- 加上此节点,保证原本就是.html类型的文件能正常访问 -->
      <buildProviders>
        <add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
      </buildProviders>

    </compilation>
    <httpRuntime />
    <customErrors mode="Off" defaultRedirect="error.html">
      <error statusCode="404" redirect="404.html" />
    </customErrors>

   <!--<httpHandlers>
      --><!--<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />--><!--
      <add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
    </httpHandlers>-->
  </system.web>

 <system.webServer>
    <handlers>
      <add  name="URLRewriter" verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
      <add name="htmltoaspxUrlWriter_32" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
      <add name="htmltoaspxUrlWriter_64" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness64" />
    </handlers>
  </system.webServer>
</configuration>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值