Session is null in ashx and in web api

Session is null in ashx

 
If the HttpContext.Current.Session is null in your .ashx handler, add System.Web.SessionState.IReadOnlySessionState to your class declaration, like this:
public class MyHandler : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
Also, if you need to write to Session[], you can use IRequresSessionState instead of IReadOnlySessionState.
see also:
http://forums.asp.net/t/1773026.aspx/1
http://stackoverflow.com/questions/7705802/httpcontext-current-session-is-null-in-mvc-3-appplication

你可能感兴趣的:(session)