Is it possible to access HttpContext.Current.Session from Web API

后端 未结 2 1157
执笔经年
执笔经年 2020-12-01 10:53

Is it possible to access HttpContext.Current.Session through a WebAPI ? can we make it inheriting IRequiresSession?

I have a generic handler doing a Session set afte

2条回答
  •  悲&欢浪女
    2020-12-01 11:08

    Casting it as HttpContext did not work for me using Web Api 2.1. However I could use HttpContextWrapper.

    var context = Request.Properties["MS_HttpContext"] as HttpContextWrapper;
    

提交回复
热议问题