Create a session in a generic application

Source: Internet
Author: User

By default, the generic application class inherits the IHttpHandler interface to allow programming of HTTP requests. The IHttpHandler interface defines a method: ProcessRequest (HttpContext context) and a property isreusable.

Context. Session state is read-only and if you want to manipulate it, implement the IRequiresSessionState interface under the System.Web.SessionState namespace. The IRequiresSessionState interface is a markup interface, and there is no method that enables the specified destination HTTP handler to have read and write access to the session-state value.


Using System;
Using System.Web;
Using System.Web.SessionState;

public class Test:ihttphandler,irequiressessionstate
{

public void ProcessRequest (HttpContext context)
{
Context. Response.ContentType = "Text/plain";
Context. Response.Write ("Hello World");

Context. session["UserID"] = 1;
}

public bool IsReusable
{
Get
{
return false;
}
}

}

Original: http://www.cnblogs.com/morsh/archive/2009/11/04/1596140.html

Create a session in a generic application

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.