1)下载安装URLRewriter,地址是
download.microsoft.com/download/0/4/6/0463611e-a3f9-490d-a08c-877a83b797cf/MSDNURLRewriting.msi
下载安装后再bin目录下找到URLRewriter.dll文件
2)项目文件添加引用URLRewriter.dll
3)配置文件的设置
3.1
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
写在<configuration>节点中,注意:如果存在<appSettings>,<connectionStrings/>应先删掉,或者放到后面
3.2在web.config文件中的system.web节点下加入如下代码
<httpHandlers>
<addverb="*"path="*.html"
type="URLRewriter.RewriterFactoryHandler, URLRewriter" /> </httpHandlers>
3.3 在<configuration>节点中,添加如下代码(注意:<RewriterConfig>要在section name="RewriterConfig"定义以后才能使用)
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/(\d+)\.html</LookFor>
<SendTo>~/default$1.aspx?ShowID=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>