URLRewriter组件实现伪静态

1.添加UrlRewriter.dll引用

2.修改Web.config

<configSections>节点下添加

<section name="ReplaceUrl" type="URLRewriter.Config.UrlsSection, URLRewriter"/>

根节点下添加

<ReplaceUrl>
<urls>
<add virtualUrl="~/about.html" destinationUrl="~/about.aspx"/>
<add virtualUrl="~/newsItem(.+).html" destinationUrl="~/newsItem.aspx?id=$1"/>
</urls>
</ReplaceUrl>

<httpModules>下添加

<add type="URLRewriter.RewriterModule, URLRewriter" name="RewriterModule"/>

 3.调用时比较

newsItem<%=news.Id %>.html

newsItem.aspx?id=<%=news.Id %>

原文地址:https://www.cnblogs.com/xyangs/p/3097386.html