net url重写用法,特此记录下

  • binGe博客
  • C#
  • 2022-1-20 22:05:07
  • 人已阅读
简介虽然已改用netcore了,但有些项目还是netframework比较方便
下载URL重写插件Intelligencia.UrlRewriter.dll ,添加到项目引用即可
webconfig配置:
<configSections>
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>

<system.web>
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
    </httpModules>
</system.web>

<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
    </modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>

<rewriter>
<rewrite url="~/info/cont(\d+)+" to="~/html/info/$1.html" />
<rewrite url="~/list/photo(\d+)+" to="~/html/list/$1-1.html" />
</rewriter>

文章评论

评论
  • 消灭零回复
Top