Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report