HttpApplication attribute Request (HttpRequest) ASP. NET

Source: Internet
Author: User

Type: system. web. httprequest
When a browser requests a page from a server, this behavior is called a request ).
The methods and attributes of the httprequest class are made public through the request attributes of the httpapplication, httpcontext, page, and usercontrol classes.
Common methods and attributes:
Common Methods:
Mappath

Request. mappath (): maps the specified virtual path to the physical path. Parameter: the virtual path (absolute or relative path) of the current request ).

Server. mappath (): returns the physical file path corresponding to the specified virtual path on the web server. Parameter: Virtual Path of the web server.

Return Value: The physical server path mapped to by the virtual path. Note: Only ing does not necessarily exist.
Special parameter: the current directory is mapped by default.
// The parameters in the current directory (./) are the same as those in the empty string. "E: solution project zz"
Request. mappath ("./");
Server. mappath ("./");

// If the parent directory (../) is already the root, an exception is thrown. "E: solution Project"
Request. mappath ("../");
Server. mappath ("../");

// Server root (/) "c: inetpubwwwroot"
Request. mappath ("../");
Server. mappath ("../");

// Virtual directory root (~ /) "E: solution Project"
Request. mappath ("~ /");
Server. mappath ("~ /");

Difference: no difference is found at present. If you encounter any difference, you can leave a message for me.
Appendix: request. mappath () overload method:
Parameters:
Virtualpath: the virtual path (absolute or relative path) of the current request ).
Basevirtualdir: the virtual base directory path used for relative resolution.
Allowcrossappmapping: true indicates that virtualpath may belong to another application; otherwise, it is false.
Return: the physical path on the server.
Note: Use the second parameter as the relative directory, and then start to map the first parameter.
Note:
The first parameter cannot start with/or ~ /Start. The second parameter is invalid.
The second parameter cannot be a relative path ~ /Start.
If the third parameter is false, the second parameter must start ~ /Start.
Example:
Request. mappath ("qq ","~ /Zz ", false); //" e: solution project zzqq"
Request. mappath ("qq", "/zz", true); // "c: inetpubwwwrootzzqq"
Request. mappath ("/qq", "/zz", true); // "c: inetpubwwwrootqq "(

Validateinput

Windows 7, windows vista, windows xp sp2, windows xp media center edition, windows xp professional x64 edition, windows xp starter edition, windows server 2008, windows server 2003, windows server 2000 sp4, windows millennium edition, windows 98

Common attributes:
Get path and url
Url: http: // localhost/asp tutorial. net/zz. aspx/info? Name = wk

Obtain the physical path:
C #. net get path: Details
Obtain request. mappath () and server. mappath () through mappath ()
Get through the request property:
// Obtain the physical file system path of the root directory of the currently running server application.
Request. physicalapplicationpath; // "e: solution Project"

// Obtain the physical file system path corresponding to the requested url.
Request. physicalpath; // "e: solution project zzzz. aspx" to obtain the virtual path and url Information:
// Obtain the virtual application root path of the asp.net tutorial application on the server :"/"
Request. applicationpath; // "/aspnet"

// Obtain the virtual path of the application root and use the waveform character (~) for the application root (~) Make the path a relative path.
Request. apprelativecurrentexecutionfilepath ;//"~ /Zz. aspx"

// Obtain the virtual path of the current request
Request. currentexecutionfilepath; // "/aspnet/zz. aspx"
Request. filepath; // "/aspnet/zz. aspx"

// Obtain the object name extension specified in the currentexecutionfilepath attribute.
Request. currentexecutionfilepathextension; // ". aspx"

// Obtain the virtual path of the current request (including the attachment path information)
Request. path; // "/aspnet/zz. aspx/info"

// Obtain the additional path information of the resource with the url extension.
Request. pathinfo; // "/info"

// Obtain information about the url of the current request.
Request. url; // "http: // localhost/aspnet/zz. aspx/inf? Name = wk"

// Obtain the original url of the current request
Request. rawurl; // "/aspnet/zz. aspx/inf? Name = wk"

// Obtain information about the url of the client's last request. The request is linked to the current url.
Request. urlreferrer; // "system. uri"
Obtain browser Information

GET request information

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.