ASP. NET obtains the original Session from the Session C # class in the underlying class library,

Source: Internet
Author: User

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

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.