• 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

  • 相关阅读:
    5月29日实验报告
    实验报告(2019年4月30日)下半部分
    实验报告(2019年4月31日)
    实验报告(2019年4月17日)
    第五章 循环结构课后反思
    实验报告(2019年4月3日)
    第一次实验报告
    503小组第三章编程作业
    第九章 结构体与共用体
    第八章 指针实验
  • 原文地址:https://www.cnblogs.com/LYunF/p/2767706.html
Copyright © 2020-2023  润新知