Get session error when using ihttpmodule in Asp.net: Session status is unavailable in this context (from: http://bbs.gimoo.net/thread/172722-1.html)

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.