ASP.NET 修改请求地址后缀

版权声明:随意乱写,切勿当真! https://blog.csdn.net/pehao/article/details/79968249


比如将以前的/index.aspx 修改为 index.do同样可以运行后台代码.只需要修改映射关系参考 .aspx默认配置

环境:  .net 4.0  IIS WIN7 X64自带的

1. 添加buildProviders节点,可以参考

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config    .aspx的配置

 <add extension=".aspx" type="System.Web.Compilation.PageBuildProvider" />

2.添加 handlers ,可以通过IIS来添加, IIS->处理程序映射->添加托管处理程序(.do -> System.Web.UI.PageHandlerFactory)
注意:这点和网上描述的不太一样,反正我按照网上说的没成功. 这样处理就可以运行.

追踪预览web.config如下:

  
<configuration> 
<system.web> <compilation debug="true" targetFramework="4.0" > <buildProviders> <add extension=".do" type="System.Web.Compilation.PageBuildProvider" /> </buildProviders> </compilation> </system.web> <system.webServer> <handlers> <add name="xxx" path="*.do" verb="*" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" preCondition="integratedMode" /> </handlers> </system.webServer></configuration>

猜你喜欢

转载自blog.csdn.net/pehao/article/details/79968249
今日推荐