System.Web.HttpContext.Current.Session is a null value problem?

Source: Internet
Author: User
Tags httpcontext

Custom HTTP handlers, inherited from IHttpHandler, no problem when writing system.web.httpcontext.current.session["Value", However, if you want to write this session to a variable or if it is empty, such as: httpcontext.current.session["value"]==null, found that the value of the session is null, and later on MSDN, see "in the Custom HTTP The handler implements the IRequiresSessionState interface to determine whether the handler needs to have read and write access to the session-state value ", and when the interface is added to the custom class, it is normal.

when writing webservice with ASP. session is not supported by default , but we can set WebMethod's enablesession option to true to open it explicitly , as follows:

[WebMethod (EnableSession = True)]

public string Login (string name)

{

context.session["name"] = name;

return name;

}

System.Web.HttpContext.Current.Session is a null value problem?

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.