ASP. NET System Object and asp.net object

Source: Internet
Author: User

ASP. NET System Object and asp.net object

I. ASP. NET System Objects
Request: used to obtain the value sent by the client during the Web Request, such as URL parameters and form parameters.
Response: The HTTP output returned by the negative to the client.
Application: the State object acting on the entire program running period. It can be used to save the configuration parameters of the entire Application.
Session: Session Status persistence object
Cookie: the client maintains session information.
Server: tool objects used for processing on servers, such as URL encoding and decoding and page forwarding.
HttpContext: encapsulate all HTTP-specific information about individual HTTP requests
Ii. Request object
String ContentType: gets or sets the MIME content type of the incoming request.
HttpCookieCollection Cookies: a set of Cookies sent by the client
HttpFileCollection Files: Get the collection of Files uploaded by the client
NameValueCollection Form: Get the data submitted by the Form
NameValueCollection Headers: Get the HTTP header set
NameValueCollection QueryString: Get the HTTP query string variable set
String RawUrl: Get the original URL of the current request
NameValueCollection ServerVariables: a set of Web server variables.
String UserAgent: obtains the original user agent information of the client browser.
String UserHostAddress: obtains the IP address of the remote client host.
String MapPath (stirng virtualPath): maps the specified virtual path to the physical path.
Void SaveAs (string filename, bool includeHeaders): saves the HTTP request to the disk.
3. Response object
String ContentType: gets or sets the http mime type of the output stream.
HttpCookieCOllection Cookies: Get Response Cookies
NameValueCollection Headers: a collection of response Headers.
Void Redirect (string url): redirects requests to the new URL
Void Write (string s): Write a string to the HTTP Response output stream.
Iv. Server objects
String MapPath (string path): returns the physical file path corresponding to the specified virtual path on the Web server.
Void Transfer (string path): Use the specified path for page forwarding
String UrlDecode (string s): perform URL Decoding on the string.
String UrlEncode (string s): URL-encoded string
V. Session Object
Syntax: Session ["Session name"] = value; // save Value
Variable = Session ["Session name"]; // Value

String SessionID: contains a unique user session identifier. It can be used to record user information throughout the session.
Int Timeout: the user's Timeout time, in minutes
Void Abandon (): ends the Session and cancels the current Session.
Void Add (string name, object value): Add Session data
Void Remove (string name): deletes Session data.

In addition to the Code setting Timeout, you can also use web. config to configure the Session.

1 <system. web> 2 <sessionState timeout = "20" cookieless = "true" mode = "InProc"> </sessionState> 3 <! -- Omit other nodes --> 4 </system. web> 5 <! -- Cookieless = "true": indicates that the Session information of the client is not dependent on the Cookie, but 6 cookieless = "false": indicates that the client uses cookies to save the SessionID7 mode: the default value is InProc, indicating that the Session State remains dependent on the current ASP. NET Process 8 StateServer and SQLServer: the Session can be saved on the Status server or database server -->

 


Vi. Cookie objects
Syntax:
Response. Cookies [Cookie name]. Value = variable Value; // write Cookie
String variable name = Request. Cookies [Cookie name]. Value; // read Cookie


The Cookie type is HttpCookie, so there is another way to add a new Cookie:
HttpCookie hcCookie = new HttpCookie ("Cookie name", "value ");
Response. Cookies. Add (hcCookie );

String Name: Cookie Object Name
String Value: Cookie object content
DateTime Expires: the effective time of the Cookie object. If no effective date is set for the Cookie, it is saved
When the program of the browser is closed and set to DateTime. MaxValue, the Cookie will never expire.
VII. Application Object
Syntax:
Application ["Application name"] = value; // save Value
Variable = Application {"Application name"]; // Value
8. HttpContext object
HttpApplicationState Application: Application Object
HttpRequest Request: Request object
HttpResponse Response: Response object
HttpServerUtility Server: Server Object
HttpSessionState Session: Session Object
IPrincipal User: User object
System. Web. Caching. Cache: Cache object
Static HttpContext Current: obtains or sets the System. Web. HttpContext object for the Current Http request.

Eg: System. Web. HttpContext. Current. Response. Redirect ("~ /");

Related Article

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.