asp.net3.5sp1WebForm使用路由
第一步:创建一个类,并集成自IRouteHandler,实现接口中的方法.
第二步:在Application_Start中注册Route
第三步: 配置Web.Config:
1.在<system.web>中添加
<httpModules>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpModules>
下面为了为了支持iis7
2、在<system.WebServer>中添加
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<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>
或者
1. System.Web->HttpModules->
<add
name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule,System.Web.Routing,
Version=3.5.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
2. system.webServer->modules->
<add
name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web.Routing,Version=3.5.0.0,
Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
3. system.webServer->handlers->
<add
name="MyRoutingHandler"
verb="*"
path="UrlRouting.axd"
type="XXX.MyRoutingHandler"/>
如果sesstion不能用
参考http://stackoverflow.com/questions/218057/httpcontext-current-session-is-null-when-routing-requests