之前使用URLRewrite在IIS6中一切正常,但是在IIS7却不能正常使用,提示“无法找到资源”,这时需要在web.config中system.webServer节点中的handlers节点进行配置,如下:
IIS6中的配置:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1 <configuration>
2 ![](https://www.cnblogs.com/Images/dot.gif)
3 <configSections>
4 <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
5 </configSections>
6 <RewriterConfig>
7 <Rules>
8 <RewriterRule>
9 <LookFor>~/Index\.aspx</LookFor>
10 <SendTo>~/Content/Index.aspx</SendTo>
11 </RewriterRule>
12 </Rules>
13 </RewriterConfig>
14
15 <system.web>
16 <httpHandlers>
17 <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter"/>
18 </httpHandlers>
19 </system.web>
20 ![](https://www.cnblogs.com/Images/dot.gif)
21 </configuration>
如果在IIS7中使用,需在web.config中加入:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1 <configuration>
2 ![](https://www.cnblogs.com/Images/dot.gif)
3 <system.webServer>
4 <validation validateIntegratedModeConfiguration="false"/>
5 <modules>
6 <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
7 </modules>
8 <system.webServer>
9 ![](https://www.cnblogs.com/Images/dot.gif)
10 </configuration>
加入以上代码后,URLRewrite就可以同时在IIS6和IIS7中正常使用了。
--EricZhang