想必很多ASP.NET的码友们在IIS配置伪静态被严重纠结过不止一次两次,本园主经过多次站点伪静态配置,总结了一下,IIS版本:IIS 6、IIS 7,服务器:Windows Server 2003、Windows Server 2008,开发机多半是Windows 7,站点.NET Framework 2.0、.NET Framework 4.0 ,随机搭配任意组合,时行时不行,完全靠运气以及人品,被虐千百遍之后,真是刻苦铭心闻者伤心见者也会流泪...
简单粗暴点吧,我认为直接帖上Web.config文件最实在
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/(\w*).html</LookFor>
<SendTo>~/Default.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/news-(\w*)_(\w*).html</LookFor>
<SendTo>~/Default.aspx?id=$1&tt=$2</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<system.web>
<!--<compilation debug="true" targetFramework="2.0" />-->
<httpHandlers>
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter"/>
<add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter"/>
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<!--.NET Framework 2.0 或 .NET Framework 4.0 二选一 -->
<!--.NET Framework 2.0 用这-->
<add name="woool1" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32"/>
<add name="woool" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32"/>
<!--64位操作系统就加上 ? -->
<add name="woool1_64" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32"/>
<add name="woool_64" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32"/>
<!--.NET Framework 2.0 用这结束-->
<!--.NET Framework 4.0 用这开始-->
<add name="woool1" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32"/>
<add name="woool" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32"/>
<!--64位操作系统就加上 ? -->
<add name="woool1_64" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32"/>
<add name="woool_64" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32"/>
<!--.NET Framework 4.0 用这结束-->
</handlers>
<!--iis 7.0 下支持 URLRewriter ? -->
<modules>
<add name="ModuleRewriter" type="URLRewriter.ModuleRewriter, URLRewriter"/>
</modules>
</system.webServer>
</configuration>