This article was reproduced from: http://www.cnblogs.com/TivonStone/archive/2012/04/06/2434796.html
Recently do a project, call the Ashx file, where the ashx file is useful to the session, but always can not get the session, after debugging, the cause of the error:
Broadly as follows
Context. session["requeststate"] = state;
Review MSDN get ashx file to use the session, you must implement the session interface, as follows
Public classQqcallbackhandle:ihttphandler,system.web.sessionstate.irequiressessionstate { Public voidProcessRequest (HttpContext context) {varQqcontext =NewQConnectSDK.Context.QzoneContext (); stringState = Guid.NewGuid (). ToString (). Replace ("-",""); stringScope =""; varAuthenticationurl =Qqcontext.getauthorizationurl (State, scope); //request token, request token secret need to be saved.//In the demo demo, it is saved directly in the global variable. The real situation needs to be handled by the website itselfContext. session["RequestState"] =State ; Context. Response.Redirect (Authenticationurl); } Public BOOLisreusable {Get { return false; } } }
(turn) ASHX use session