Draft for Information Only
Content
Request Object Examples Source/Reference
Request Object
The Request object is an instance of the System.Web.HttpRequest class.
Request object of ASP.NET is related to
retrieving data by the server from the
client.
Tthe Request property of the Page class can be use to access the HttpRequest instance for the current request. For example, Request["key"] can be used for accessing data from the QueryString, Form, Cookies, or ServerVariables collections.
The methods and properties of the HttpRequest class are exposed through the Request properties of the HttpApplication, HttpContext, Page, and UserControl classes.
Note: Unicode support for HttpRequest class members requires IIS version 6.0 or later.
Examples
Examples of Request Properties
ASP.NET Code Input: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script LANGUAGE="VBScript" runat="server" >
Sub Page_Load()
Dim xstr As String =""
Dim xarry() As Object = {"AcceptTypes","AnonymousID","ApplicationPath","AppRelativeCurrentExecutionFilePath","Browser","ClientCertificate","ContentEncoding","ContentLength","ContentType","Cookies","CurrentExecutionFilePath","FilePath","Files","Filter","Form","Headers","HttpChannelBinding","HttpMethod","InputStream","IsAuthenticated","IsLocal","IsSecureConnection","Item[String]","LogonUserIdentity","Params","Path","PathInfo","PhysicalApplicationPath","PhysicalPath","QueryString","RawUrl","RequestType","ServerVariables","TotalBytes","Url","UrlReferrer","UserAgent","UserHostAddress","UserHostName","UserLanguages"}
xstr = "Request.AcceptTypes(0): " + Request.AcceptTypes(0) + "<br />"
xstr = xstr + "Request.AnonymousID: " + Request.AnonymousID + "<br />"
xstr = xstr + "Request.ApplicationPath: " + Request.ApplicationPath + "<br />"
xstr = xstr + "Request.AppRelativeCurrentExecutionFilePath: " + Request.AppRelativeCurrentExecutionFilePath + "<br />"
xstr = xstr + "Request.Browser(0): " + Request.Browser(0) + "<br />"
xstr = xstr + "Request.ClientCertificate.Issuer: " + Request.ClientCertificate.Issuer + "<br />"
xstr = xstr + "Request.ContentEncoding.EncodingName: " + Request.ContentEncoding.EncodingName + "<br />"
xstr = xstr + "Request.ContentLength: " + Request.ContentLength.ToString + "<br />"
xstr = xstr + "Request.ContentType: " + Request.ContentType + "<br />"
xstr = xstr + "Request.Cookies.Count: " + Request.Cookies.Count.ToString + "<br />"
xstr = xstr + "Request.CurrentExecutionFilePath: " + Request.CurrentExecutionFilePath + "<br />"
xstr = xstr + "Request.FilePath: " + Request.FilePath + "<br />"
xstr = xstr + "Request.Files.Count: " + Request.Files.Count.ToString + "<br />"
xstr = xstr + "Request.Filter.Length: " + Request.Filter.Length.ToString + "<br />"
xstr = xstr + "Request.Form.Count: " + Request.Form.Count.ToString + "<br />"
xstr = xstr + "Request.Headers: " + Request.Headers.ToString + "<br />"
xstr = xstr + "Request.HttpChannelBinding.Size: " + Request.HttpChannelBinding.Size.ToString + "<br />"
xstr = xstr + "Request.HttpMethod: " + Request.HttpMethod + "<br />"
xstr = xstr + "Request.InputStream: " + Request.InputStream.Length.ToString + "<br />"
xstr = xstr + "Request.IsAuthenticated: " + Request.IsAuthenticated.ToString + "<br />"
xstr = xstr + "Request.IsLocal: " + Request.IsLocal.ToString + "<br />"
xstr = xstr + "Request.IsSecureConnection: " + Request.IsSecureConnection.ToString + "<br />"
xstr = xstr + "Request.Item(""Url""): " + Request.Item("Url") + "<br />"
xstr = xstr + "Request.LogonUserIdentity: " + Request.LogonUserIdentity.ToString + "<br />"
xstr = xstr + "Request.Params: " + Request.Params.ToString + "<br />"
xstr = xstr + "Request.Path: " + Request.Path + "<br />"
xstr = xstr + "Request.PathInfo: " + Request.PathInfo + "<br />"
xstr = xstr + "Request.PhysicalApplicationPath: " + Request.PhysicalApplicationPath + "<br />"
xstr = xstr + "Request.PhysicalPath: " + Request.PhysicalPath + "<br />"
xstr = xstr + "Request.QueryString: " + Request.QueryString.ToString + "<br />"
xstr = xstr + "Request.RawUrl: " + Request.RawUrl + "<br />"
xstr = xstr + "Request.RequestType: " + Request.RequestType + "<br />"
xstr = xstr + "Request.ServerVariables: " + Request.ServerVariables.ToString + "<br />"
xstr = xstr + "Request.TotalBytes: " + Request.TotalBytes.ToString + "<br />"
xstr = xstr + "Request.Url: " + Request.Url.ToString + "<br />"
xstr = xstr + "IsNothing(Request.UrlReferrer): " + IsNothing(Request.UrlReferrer).ToString + "<br />"
xstr = xstr + "Request.UserAgent: " + Request.UserAgent + "<br />"
xstr = xstr + "Request.UserHostAddress: " + Request.UserHostAddress + "<br />"
xstr = xstr + "Request.UserHostName: " + Request.UserHostName + "<br />"
xstr = xstr + "IsNothing(Request.UserLanguages): " + IsNothing(Request.UserLanguages).ToString + "<br />"
lbl01z.InnerHTML=replace(xstr,"&","&")
End Sub
</script>
</head>
<body>
<% Response.Write ("<h1>This is a Sample Page of Request Properties</h1>") %>
<div id="lbl01z" runat="server"></div>
</body>
</html>
HTTP Response Output: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<h1>This is a Sample Page of Request Properties</h1><div id="lbl01z">Request.AcceptTypes(0): image/*<br />Request.AnonymousID: <br />Request.ApplicationPath: /test<br />Request.AppRelativeCurrentExecutionFilePath: ~/test0/aspnet/aspnet_builtin_object_request_property_001a_01.aspx<br />Request.Browser(0): <br />Request.ClientCertificate.Issuer: <br />Request.ContentEncoding.EncodingName: Unicode (UTF-8)<br />Request.ContentLength: 0<br />Request.ContentType: application / x - www - form - urlencoded<br />Request.Cookies.Count: 0<br />Request.CurrentExecutionFilePath: /test/test0/aspnet/aspnet_builtin_object_request_property_001a_01.aspx<br />Request.FilePath: /test/test0/aspnet/aspnet_builtin_object_request_property_001a_01.aspx<br />Request.Files.Count: 0<br />Request.Filter.Length: 0<br />Request.Form.Count: 0<br />Request.Headers: Content-Type=application+%2f+x+-+www+-+form+-+urlencoded&Accept=image%2f*&Host=127.0.0.1&User-Agent=Mozilla%2f4.0+(compatible%3b+MSIE+5.01%3b+Windows+NT+5.0)<br />Request.HttpChannelBinding.Size: 0<br />Request.HttpMethod: GET<br />Request.InputStream: 0<br />Request.IsAuthenticated: False<br />Request.IsLocal: True<br />Request.IsSecureConnection: False<br />Request.Item("Url"): /test/test0/aspnet/aspnet_builtin_object_request_property_001a_01.aspx<br />Request.LogonUserIdentity: System.Security.Principal.WindowsIdentity<br />Request.Params: ALL_HTTP=HTTP_CONTENT_TYPE%3aapplication+%2f+x+-+www+-+form+-+urlencoded%0d%0aHTTP_ACCEPT%3aimage%2f*%0d%0aHTTP_HOST%3a127.0.0.1%0d%0aHTTP_USER_AGENT%3aMozilla%2f4.0+(compatible%3b+MSIE+5.01%3b+Windows+NT+5.0)%0d%0a&ALL_RAW=Content-Type%3a+application+%2f+x+-+www+-+form+-+urlencoded%0d%0aAccept%3a+image%2f*%0d%0aHost%3a+127.0.0.1%0d%0aUser-Agent%3a+Mozilla%2f4.0+(compatible%3b+MSIE+5.01%3b+Windows+NT+5.0)%0d%0a&APPL_MD_PATH=%2fLM%2fW3SVC%2f3%2fROOT%2ftest&APPL_PHYSICAL_PATH=R%3a%5cwebs%5ctest%5c&AUTH_TYPE=&AUTH_USER=&AUTH_PASSWORD=&LOGON_USER=&REMOTE_USER=&CERT_COOKIE=&CERT_FLAGS=&CERT_ISSUER=&CERT_KEYSIZE=&CERT_SECRETKEYSIZE=&CERT_SERIALNUMBER=&CERT_SERVER_ISSUER=&CERT_SERVER_SUBJECT=&CERT_SUBJECT=&CONTENT_LENGTH=0&CONTENT_TYPE=application+%2f+x+-+www+-+form+-+urlencoded&GATEWAY_INTERFACE=CGI%2f1.1&HTTPS=off&HTTPS_KEYSIZE=&HTTPS_SECRETKEYSIZE=&HTTPS_SERVER_ISSUER=&HTTPS_SERVER_SUBJECT=&INSTANCE_ID=3&INSTANCE_META_PATH=%2fLM%2fW3SVC%2f3&LOCAL_ADDR=127.0.0.1&PATH_INFO=%2ftest%2ftest0%2faspnet%2faspnet_builtin_object_request_property_001a_01.aspx&PATH_TRANSLATED=R%3a%5cwebs%5ctest%5ctest0%5caspnet%5caspnet_builtin_object_request_property_001a_01.aspx&QUERY_STRING=&REMOTE_ADDR=127.0.0.1&REMOTE_HOST=127.0.0.1&REMOTE_PORT=50038&REQUEST_METHOD=GET&SCRIPT_NAME=%2ftest%2ftest0%2faspnet%2faspnet_builtin_object_request_property_001a_01.aspx&SERVER_NAME=127.0.0.1&SERVER_PORT=80&SERVER_PORT_SECURE=0&SERVER_PROTOCOL=HTTP%2f1.1&SERVER_SOFTWARE=Microsoft-IIS%2f8.5&URL=%2ftest%2ftest0%2faspnet%2faspnet_builtin_object_request_property_001a_01.aspx&HTTP_CONTENT_TYPE=application+%2f+x+-+www+-+form+-+urlencoded&HTTP_ACCEPT=image%2f*&HTTP_HOST=127.0.0.1&HTTP_USER_AGENT=Mozilla%2f4.0+(compatible%3b+MSIE+5.01%3b+Windows+NT+5.0)<br />Request.Path: /test/test0/aspnet/aspnet_builtin_object_request_property_001a_01.aspx<br />Request.PathInfo: <br />Request.PhysicalApplicationPath: R:\webs\test\<br />Request.PhysicalPath: R:\webs\test\test0\aspnet\aspnet_builtin_object_request_property_001a_01.aspx<br />Request.QueryString: <br />Request.RawUrl: /test/test0/aspnet/aspnet_builtin_object_request_property_001a_01.aspx<br />Request.RequestType: GET<br />Request.ServerVariables: ALL_HTTP=HTTP_CONTENT_TYPE%3aapplication+%2f+x+-+www+-+form+-+urlencoded%0d%0aHTTP_ACCEPT%3aimage%2f*%0d%0aHTTP_HOST%3a127.0.0.1%0d%0aHTTP_USER_AGENT%3aMozilla%2f4.0+(compatible%3b+MSIE+5.01%3b+Windows+NT+5.0)%0d%0a&ALL_RAW=Content-Type%3a+application+%2f+x+-+www+-+form+-+urlencoded%0d%0aAccept%3a+image%2f*%0d%0aHost%3a+127.0.0.1%0d%0aUser-Agent%3a+Mozilla%2f4.0+(compatible%3b+MSIE+5.01%3b+Windows+NT+5.0)%0d%0a&APPL_MD_PATH=%2fLM%2fW3SVC%2f3%2fROOT%2ftest&APPL_PHYSICAL_PATH=R%3a%5cwebs%5ctest%5c&AUTH_TYPE=&AUTH_USER=&AUTH_PASSWORD=&LOGON_USER=&REMOTE_USER=&CERT_COOKIE=&CERT_FLAGS=&CERT_ISSUER=&CERT_KEYSIZE=&CERT_SECRETKEYSIZE=&CERT_SERIALNUMBER=&CERT_SERVER_ISSUER=&CERT_SERVER_SUBJECT=&CERT_SUBJECT=&CONTENT_LENGTH=0&CONTENT_TYPE=application+%2f+x+-+www+-+form+-+urlencoded&GATEWAY_INTERFACE=CGI%2f1.1&HTTPS=off&HTTPS_KEYSIZE=&HTTPS_SECRETKEYSIZE=&HTTPS_SERVER_ISSUER=&HTTPS_SERVER_SUBJECT=&INSTANCE_ID=3&INSTANCE_META_PATH=%2fLM%2fW3SVC%2f3&LOCAL_ADDR=127.0.0.1&PATH_INFO=%2ftest%2ftest0%2faspnet%2faspnet_builtin_object_request_property_001a_01.aspx&PATH_TRANSLATED=R%3a%5cwebs%5ctest%5ctest0%5caspnet%5caspnet_builtin_object_request_property_001a_01.aspx&QUERY_STRING=&REMOTE_ADDR=127.0.0.1&REMOTE_HOST=127.0.0.1&REMOTE_PORT=50038&REQUEST_METHOD=GET&SCRIPT_NAME=%2ftest%2ftest0%2faspnet%2faspnet_builtin_object_request_property_001a_01.aspx&SERVER_NAME=127.0.0.1&SERVER_PORT=80&SERVER_PORT_SECURE=0&SERVER_PROTOCOL=HTTP%2f1.1&SERVER_SOFTWARE=Microsoft-IIS%2f8.5&URL=%2ftest%2ftest0%2faspnet%2faspnet_builtin_object_request_property_001a_01.aspx&HTTP_CONTENT_TYPE=application+%2f+x+-+www+-+form+-+urlencoded&HTTP_ACCEPT=image%2f*&HTTP_HOST=127.0.0.1&HTTP_USER_AGENT=Mozilla%2f4.0+(compatible%3b+MSIE+5.01%3b+Windows+NT+5.0)<br />Request.TotalBytes: 0<br />Request.Url: http://127.0.0.1/test/test0/aspnet/aspnet_builtin_object_request_property_001a_01.aspx<br />IsNothing(Request.UrlReferrer): True<br />Request.UserAgent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)<br />Request.UserHostAddress: 127.0.0.1<br />Request.UserHostName: 127.0.0.1<br />IsNothing(Request.UserLanguages): True<br /></div>
</body>
</html>
HTML Web Page Embedded Output:
Source/Reference
©sideway
ID: 201100013 Last Updated: 11/13/2020 Revision: 0 Ref:
References
Active Server Pages, , http://msdn.microsoft.com/en-us/library/aa286483.aspx
ASP Overview, , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
ASP Best Practices, , http://technet.microsoft.com/en-us/library/cc939157.aspx
ASP Built-in Objects, , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
Response Object, , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
Request Object, , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
Server Object (IIS), , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
Application Object (IIS), , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
Session Object (IIS), , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
ASPError Object, , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
ObjectContext Object (IIS), , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
Debugging Global.asa Files, , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
How to: Debug Global.asa files, , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
Calling COM Components from ASP Pages, , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
IIS ASP Scripting Reference, , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
ASP Keywords, , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
Creating Simple ASP Pages, , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
Including Files in ASP Applications, , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
ASP Overview, , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
FileSystemObject Object, , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx, , ADO Object Model
ADO Fundamentals, , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx