使用routing
看了重典的两篇文章
System.Web.Routing入门及进阶 上篇
System.Web.Routing入门及进阶 下篇
仿照其中的进行了操作,发现怎么不都起作用,非常奇怪,搜了好多才找到了解决方案
是在MSDN上找到的,如下:
To configure an ASP.NET Web site project for routing
In the application's Web.config file, add the ASP.NET routing assembly to the assemblies element, as shown in the following example:
Copy Code
<add assembly="System.Web.Routing, Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
If the application runs under IIS 6.0 or IIS 7.0 Classic mode , add the UrlRoutingModule class to the httpModules element, as shown in the following example:
Copy Code
<httpModules>
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule,
System.Web.Routing,
Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
If the application runs under IIS 7.0 Integrated mode , add the UrlRoutingModule class to the modules element, as shown in the following example:
Copy Code
<system.webServer>
<modules>
<remove name="UrlRoutingModule" />
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule,
System.Web.Routing,
Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
</modules>
</system.webServer>
If the application runs under IIS 7.0 Integrated mode, add the UrlRoutingHandler class to the handlers element as shown in the following example:
Copy Code
<system.webServer>
<handlers>
<add name="UrlRoutingHandler"
preCondition="integratedMode"
verb="*"
path="UrlRouting.axd"
type="System.Web.HttpForbiddenHandler,
System.Web, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
需要在web.config中进行以上配置
1是必须的,而2是针对IIS的经典模式的
而我用的是IIS7的集成模式
所以需要进行3和4的配置,按照3和4进行了操作以后
就成功了!
标签: ASP.NET
作者: Leo_wl
出处: http://HdhCmsTestcnblogs测试数据/Leo_wl/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
版权信息