Httpmodule:
Public void Init (httpapplication context)
{
Context. acquirerequeststate + = new eventhandler (context_acquirerequeststate );
}
Void context_acquirerequeststate (Object sender, eventargs E)
{
Httpapplication application = (httpapplication) sender;
String url = application. Request. url. tostring ();
String username = convert. tostring (application. session ["username"]);
......
Application. session ["username"] error: Session status is unavailable in this context
How can I obtain a session in httpmodule? Thank you for your help ..
==================================Solution====================================
My research results:
First, httpmodule corresponds to all requests, so some non-aspx requests also enter. Similar to xx.css
In this case, there will be no session, and an error will occur when you retrieve the session value. Second, I used to configure the action in the filter method used in Java. The URL is not directly written to XX. aspx, but with the module method XX/XXX/xx, sessioin will not be obtained.
I am not very familiar with the httpmodule of DOTNET. If you have better explanations or methods, please talk about it...
I will close the post tomorrow. Thank you.