ASP. NET obtains the original Session from the Session C # class in the underlying class library,
To obtain a Session in the class library, you must add references first.
Get Session
Copy codeThe Code is as follows:
String user = (string) HttpContext. Current. Session ["user"];
Get Page
Copy codeThe Code is as follows:
System. Web. UI. Page page = (System. Web. UI. Page) HttpContext. Current. Handler;
Obtain the current Request Response and other objects here
Copy codeThe Code is as follows:
HttpResponse response = System. Web. HttpContext. Current. Response;
HttpRequest request = System. Web. HttpContext. Current. Request;
Articles you may be interested in:
- Asp.net BasePage class + Session General user logon permission Control
- The ultimate solution to the problem that Session is easy to lose after ASP. NET State Service is enabled on the IIS server
- ASP. NET Website management system exit to clear browser cache, Session code
- In ASP. NET, set the Session expiration time
- ASP. NET cannot judge the user's login and Session loss in IE10. Solution
- Differences between Session Cache and Cache in asp.net
- Comparison of several methods for Judging session expiration in asp.net
- Asp.net solves Session problems in the ashx File
- Introduction to using session in general processing programs in ASP. NET
- Methods for obtaining sessions in ASP. NET ASHX
- Simple Chat Room program written by ASP. NET using application and session Object