• Web API 开启Session的配置


    • Web API本身是默认没有开启Session配置的
    • 建立SessionRouteHandler.cs和SessionControllerRouteHandler.cs并覆写类HttpControllerHandler、IRequiresSessionState、HttpControllerRouteHandler
    1 public class SessionRouteHandler: HttpControllerHandler, IRequiresSessionState{
    2     public SessionRouteHandler(RouteData routeData) : base(routeData){ }
    3 }
    4 public class SessionControllerRouteHandler: HttpControllerRouteHandler{
    5     protected override IHttpHandler GetHttpHandler(RequestContext requestContext){
    6         return new SessionRouteHandler(requestContext.RouteData);
    7     }
    8 } 
    • 在WebApiConfig.cs中将config.Routes.MapHttpRoute 改成RouteTable.Routes.MapHttpRoute(using System.Web.Routing)并指定RouteHandler
    1 RouteTable.Routes.MapHttpRoute(
    2     name: "ActionApi",
    3     routeTemplate: "actionapi/{controller}/{action}/{id}",
    4     defaults: new { id = RouteParameter.Optional }).RouteHandler = new SessionControllerRouteHandler();
     
  • 相关阅读:
    HDU4565
    CF861D
    UVA 11651
    HDU5950
    POJ3267
    POJ1094
    POJ1905
    HDU3567
    进程的同步与互斥
    预防死锁,检测死锁,避免死锁,解除死锁....
  • 原文地址:https://www.cnblogs.com/My-Sun-Shine/p/13509613.html
Copyright © 2020-2023  润新知