Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand the use of session in general handlers in ASP.NET

Shulou Source: shulou.com Published: 2022-06-03 07:38:01 10月01日 Update

This article mainly explains "how to understand ASP.NET in the general process of using session," interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's take you to learn "how to understand ASP.NET in the general process of using session" bar!

The copy code is as follows:

using System;

using System.Web;

using System.Web.SessionState;

public class ChangePwd : IHttpHandler, IReadOnlySessionState

{

public void ProcessRequest (HttpContext context)

{

context.Response.ContentType = "text/plain";

OperUser ou = new OperUser();

if (ou.ChangeWsPassword(context.Session["ws_user"].ToString(),context.Request.QueryString["pwd"].ToString()))

{

context.Response.Write("true");

}

else

{

context.Response.Write("flase");

}

}

public bool IsReusable {

get {

return false;

}

}

}

Plus using System.Web.SessionState; and IReadOnlySessionState

If your handler is to access session-state values, it must implement the IRequiresSessionState interface (a markup interface that does not contain any methods).

import using System.Web.SessionState;

Sure enough, just add an IRequiresSessionState tag interface to your custom class and you don't need to implement any methods.

Along with this, there is another interface: the IReadOnlySessionState interface, which indicates to the Http handler that it has read-only permissions on Session, which is also a null interface and does not require any method implementation.

At this point, I believe that we have a deeper understanding of "how to understand ASP.NET in the general process of using session," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Interfaces programs processing methods code content tags learning practicality deeper interest at the same time practicality practice instructions simple operation more friends permissions status Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Redmi NVidia Shulou Information macOS