Asp. NET kernel several large objects, ASP. NET Core Knowledge (6)

Source: Internet
Author: User
Tags allkeys html encode urlencode

description In fact, today's blog is the general processing of the next part of the process, in theory should be called General processing program (2). But I think the series name after the article title already has a number, add a 2 a bit strange. This post mainly introduces several objects. 1) HttpContext2) HttpRequest3) HttpResponse4) context. Serverhttpcontext1a Context object that describes the object to which this request relates, and generally obtains other objects through it. 2. Clipboard3description of the httpcontext.current in the HttpHandler ProcessRequest method, the object can be obtained through the method's context parameter. In other places, the HttpContext object in the current request stack can be obtained through httpcontext.current, but it is advisable to pass through the parameters. (*) in a child thread is unable to get httpcontext.currenthttprequest1. Describes the context. request["username"]; In this way, a HttpRequest object can be obtained. The HttpRequest object describes the information about the request, and we can get the request data we want through this object. 2. You can see through the context through Visual Studio. Request can be obtained to a HttpRequest object j[}pnw8_25db3. Get several ways to request data1) context. request.form["username"] to get the value in the POST request,2) context. request.querystring["username"] Gets the value in the GET request. (PS: "XXX? Name=xx&age=8"called QueryString request parameter)3) context. request["username"] Take the order from QueryString, Form, Cookies, ServerVariables, the first to find is (anti-compilation verification) although using request[] this way to obtain the request data, the efficiency will be slightly reduced (almost negligible),     But it's really convenient to use. I recommend using this! 4The type request parameter for the request data gets the string type data because the HTTP protocol is text. So to get the data requested, most of the data needs to be converted. 5. Get some request information through the HttpRequest object1) Browser context. Request.Browser.Browser2) operating System information context. Request.Browser.Platform3) Browser kernel version context. Request.Browser.Version4) Request message Header//request.headers Request Packet Header for(inti =0; I < context. Request.Headers.AllKeys.Length; i++){     stringKey =context.     Request.headers.allkeys[i]; stringValue =context.     Request.headers[key]; Context. Response.Write (Key+"="+ Value +"\ n"); } 5Gets the request mode (GET or POST?). ) context. Request.httpmethod6Gets the request page file path (relative) context. Request.path7gets the request parameter context. Request.QueryString8The physical path to the requested file on the server context. Request.PhysicalPath9) Gets the user agent context. Request.useragentTen) The IP address of the client context.Request.UserHostAddress Onegets the information about the URL of the client's last request context. Request.urlreferrer AThe browser supports what language context. Request.UserLanguages PS: Yes, no mistake, look familiar on the right. These requests are described in more detail in the HTTP protocol! All information obtained by HttpRequest is from the HTTP request message. HttpResponse1. Introduction HttpResponse is an object that is set on a response message. Through the context. Response can get HttpResponse objects. 2the context can be observed through visual Studio. Response will get a HttpResponse object. clipboard[1]3. redirect Redirect () redirect; Redirect is a 302 redirect to the browser, is the notification browser "Please revisit URL this url", this process experienced the server to notify the browser "please revisit URL this url" and the browser to the command to access the new URL process. Use the Message tool to view HTTP messages throughout the response process. With redirect because it is the browser to re-visit the new URL, so in the address bar can see the changes in the URL. 4. End () end () sends all current buffered output to the client, stopping the execution of the page. By doing a try on end (), it is found that the exception was thrown. So the code after end () will not be executed. Context. Server1. Description server is an object of type HttpServerUtility, not a class name2. MapPath MapPath ("~/a.htm") The virtual path (~represents the project root) is converted to an absolute path on disk, and the files in the action project are used. 3. HtmlEncode and HtmlDecode HtmlEncode, htmldecode:html encode and decode. Encode in order to display the special character escapes .4. UrlEncode and UrlDecode UrlEncode, Urldecode:url encode and decode. Kanji, special characters (spaces, angle brackets), etc. to be encoded when passing through a URL

Source: http://www.cnblogs.com/mcad/p/4345744.html

Asp. NET kernel several large objects, ASP. NET Core Knowledge (6)

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.