ASP.NET 提供了幾個系統物件,可以用來存取許多相當有用的資訊,例如取得使用者IP,瀏覽器種類等等。 這類物件必須透過 Page 物件的屬性取得,包含:
Response
Request
Request 方法
| 方法 | 說明 |
| MapPath | 將用戶端目前要求之 URL 的虛擬路徑對應至伺服器上的實體路徑。 |
| SaveAs | Saves the request to a file. |
| ValidateInput | 是否對透過 Cookies、Form 和 QueryString 屬性執行潛在危險之驗證 |
Request 屬性
屬性 | 資料 | 說明 |
ApplicationPath | / | |
AppRelativeCurrentExecutionFilePath | ~/C08_Programming_the_Web_Application/WebForm2.aspx | 取得應用程式的虛擬路徑 |
Browser | System.Web.Mobile.MobileCapabilities | 取得用戶端瀏覽器的資訊。 |
ClientCertificate | System.Web.HttpClientCertificate | |
Cookies | System.Web.HttpCookieCollection | 取得用戶端送出的 Cookie 的集合。 |
FilePath | /C08_Programming_the_Web_Application/WebForm2.aspx | 目前要求的虛擬路徑。 |
Files | System.Web.HttpFileCollection | |
Filter | | |
Headers | Cache-Control=no-cache&Connection=Keep-Alive&Content-Length=429&Content-Type=application%2fx-www-form-urlencoded&Accept=text%2fhtml%2c+application%2fxhtml%2bxml%2c+*%2f*&Accept-Encoding=gzip%2c+deflate&Accept-Language=zh-TW&Cookie=ASP.NET_SessionId%3drzsgttim0kc0sagrgm4l0nvi&Host=localhost%3a60755&Referer=http%3a%2f%2flocalhost%3a60755%2fC08_Programming_the_Web_Application%2fWebForm2.aspx&User-Agent=Mozilla%2f5.0+(compatible%3b+MSIE+9.0%3b+Windows+NT+6.1%3b+WOW64%3b+Trident%2f5.0%3b+NP06) | |
HttpMethod | POST | |
IsAuthenticated | True | |
IsLocal | True | |
IsSecureConnection | False | |
LogonUserIdentity | System.Security.Principal.WindowsIdentity | |
Params | Name | Value | 說明 | __EVENTVALIDATION | /wEWEAKy+bbNBgKf7OeoAgLw/96vBwKu+JOJCwKKkYyiBAKx6YT7DQKiotE5AveptakBAvGhyJwOApnC0/UMAu7CqaMOAvTX2fcMAuPv3sAFAqfzke4GAubYlJQIArur8Z0KILtAbiO7t33VgM69Ar+iv7lOgtaa23CBQcz9pJqpbQg= | | __VIEWSTATE | /wEPDwUKLTc4NzI2MDczNmQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgIFDGNiSW5jbHVkZVVybAUKY2JTaG93VGV4dGOWKpza/lXYoFZ5KMT+pWaUtalW0DTOMQ0iHhxiDaw+ | | ALL_HTTP | HTTP_CACHE_CONTROL:no-cache HTTP_CONNECTION:Keep-Alive HTTP_CONTENT_LENGTH:420 HTTP_CONTENT_TYPE:application/x-www-form-urlencoded HTTP_ACCEPT:text/html, application/xhtml+xml, */* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:zh-TW HTTP_COOKIE:ASP.NET_SessionId=ent0y41l14cd4yizcegchl0o HTTP_HOST:localhost:60755 HTTP_REFERER:http://localhost:60755/C08_Programming_the_Web_Application/WebForm2.aspx HTTP_USER_AGENT:Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; NP06)
| | ALL_RAW | Cache-Control: no-cache Connection: Keep-Alive Content-Length: 420 Content-Type: application/x-www-form-urlencoded Accept: text/html, application/xhtml+xml, */* Accept-Encoding: gzip, deflate Accept-Language: zh-TW Cookie: ASP.NET_SessionId=ent0y41l14cd4yizcegchl0o Host: localhost:60755 Referer: http://localhost:60755/C08_Programming_the_Web_Application/WebForm2.aspx User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; NP06)
| | APPL_MD_PATH | | | APPL_PHYSICAL_PATH | D:\myMCTS\VitoPractice\70-528\Practice70515\ | | ASP.NET_SessionId | ent0y41l14cd4yizcegchl0o | | AUTH_PASSWORD | | | AUTH_TYPE | NTLM | | AUTH_USER | VITO-2011W7\Administrator | | btnParams | Request's Params | | cbShowText | on | | CERT_COOKIE | | | CERT_FLAGS | | | CERT_ISSUER | | | CERT_KEYSIZE | | | CERT_SECRETKEYSIZE | | | CERT_SERIALNUMBER | | | CERT_SERVER_ISSUER | | | CERT_SERVER_SUBJECT | | | CERT_SUBJECT | | | CONTENT_LENGTH | 420 | | CONTENT_TYPE | application/x-www-form-urlencoded | | GATEWAY_INTERFACE | | | HTTP_ACCEPT | text/html, application/xhtml+xml, */* | | HTTP_ACCEPT_ENCODING | gzip, deflate | | HTTP_ACCEPT_LANGUAGE | zh-TW | | HTTP_CACHE_CONTROL | no-cache | | HTTP_CONNECTION | Keep-Alive | | HTTP_CONTENT_LENGTH | 420 | | HTTP_CONTENT_TYPE | application/x-www-form-urlencoded | | HTTP_COOKIE | ASP.NET_SessionId=ent0y41l14cd4yizcegchl0o | | HTTP_HOST | localhost:60755 | | HTTP_REFERER | http://localhost:60755/C08_Programming_the_Web_Application/WebForm2.aspx | | HTTP_USER_AGENT | Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; NP06) | | HTTPS | | | HTTPS_KEYSIZE | | | HTTPS_SECRETKEYSIZE | | | HTTPS_SERVER_ISSUER | | | HTTPS_SERVER_SUBJECT | | | INSTANCE_ID | | | INSTANCE_META_PATH | | | LOCAL_ADDR | ::1 | | LOGON_USER | VITO-2011W7\Administrator | | PATH_INFO | /C08_Programming_the_Web_Application/WebForm2.aspx | | PATH_TRANSLATED | D:\myMCTS\VitoPractice\70-528\Practice70515\C08_Programming_the_Web_Application\WebForm2.aspx | | QUERY_STRING | | | REMOTE_ADDR | ::1 | | REMOTE_HOST | ::1 | | REMOTE_PORT | | | REMOTE_USER | VITO-2011W7\Administrator | | REQUEST_METHOD | POST | | SCRIPT_NAME | /C08_Programming_the_Web_Application/WebForm2.aspx | | SERVER_NAME | localhost | | SERVER_PORT | 60755 | | SERVER_PORT_SECURE | 0 | | SERVER_PROTOCOL | HTTP/1.1 | | SERVER_SOFTWARE | | | URL | /C08_Programming_the_Web_Application/WebForm2.aspx | | | 取得 QueryString、Form、Cookies 和 ServerVariables 項目的組合集合。 |
Path | /C08_Programming_the_Web_Application/WebForm2.aspx | 取得目前要求的虛擬路徑。 |
PathInfo | | |
PhysicalApplicationPath | D:\myMCTS\VitoPractice\70-528\Practice70515\ | 取得目前正在執行的伺服器應用程式的根目錄之實體檔案系統路徑。 |
PhysicalPath | D:\myMCTS\VitoPractice\70-528\Practice70515\C08_Programming_the_Web_Application\WebForm2.aspx | 取得對應到要求的 URL 之實體檔案系統路徑。 |
QueryString | User=vito&Page=2 | 取得 HTTP 查詢字串變數的集合。 |
RawUrl | /C08_Programming_the_Web_Application/WebForm2.aspx | |
ServerVariables | Name | Value | 說明 | ALL_HTTP | HTTP_CACHE_CONTROL:no-cache HTTP_CONNECTION:Keep-Alive HTTP_CONTENT_LENGTH:438 HTTP_CONTENT_TYPE:application/x-www-form-urlencoded HTTP_ACCEPT:text/html, application/xhtml+xml, */* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:zh-TW HTTP_COOKIE:ASP.NET_SessionId=ent0y41l14cd4yizcegchl0o HTTP_HOST:localhost:60755 HTTP_REFERER:http://localhost:60755/C08_Programming_the_Web_Application/WebForm2.aspx HTTP_USER_AGENT:Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; NP06)
| | ALL_RAW | Cache-Control: no-cache Connection: Keep-Alive Content-Length: 438 Content-Type: application/x-www-form-urlencoded Accept: text/html, application/xhtml+xml, */* Accept-Encoding: gzip, deflate Accept-Language: zh-TW Cookie: ASP.NET_SessionId=ent0y41l14cd4yizcegchl0o Host: localhost:60755 Referer: http://localhost:60755/C08_Programming_the_Web_Application/WebForm2.aspx User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; NP06)
| | APPL_MD_PATH | | | APPL_PHYSICAL_PATH | D:\myMCTS\VitoPractice\70-528\Practice70515\ | | AUTH_PASSWORD | | | AUTH_TYPE | NTLM | | AUTH_USER | VITO-2011W7\Administrator | | CERT_COOKIE | | | CERT_FLAGS | | | CERT_ISSUER | | | CERT_KEYSIZE | | | CERT_SECRETKEYSIZE | | | CERT_SERIALNUMBER | | | CERT_SERVER_ISSUER | | | CERT_SERVER_SUBJECT | | | CERT_SUBJECT | | | CONTENT_LENGTH | 438 | | CONTENT_TYPE | application/x-www-form-urlencoded | | GATEWAY_INTERFACE | | | HTTP_ACCEPT | text/html, application/xhtml+xml, */* | | HTTP_ACCEPT_ENCODING | gzip, deflate | | HTTP_ACCEPT_LANGUAGE | zh-TW | | HTTP_CACHE_CONTROL | no-cache | | HTTP_CONNECTION | Keep-Alive | | HTTP_CONTENT_LENGTH | 438 | | HTTP_CONTENT_TYPE | application/x-www-form-urlencoded | | HTTP_COOKIE | ASP.NET_SessionId=ent0y41l14cd4yizcegchl0o | | HTTP_HOST | localhost:60755 | | HTTP_REFERER | http://localhost:60755/C08_Programming_the_Web_Application/WebForm2.aspx | | HTTP_USER_AGENT | Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; NP06) | | HTTPS | | | HTTPS_KEYSIZE | | | HTTPS_SECRETKEYSIZE | | | HTTPS_SERVER_ISSUER | | | HTTPS_SERVER_SUBJECT | | | INSTANCE_ID | | | INSTANCE_META_PATH | | | LOCAL_ADDR | ::1 | | LOGON_USER | VITO-2011W7\Administrator | | PATH_INFO | /C08_Programming_the_Web_Application/WebForm2.aspx | | PATH_TRANSLATED | D:\myMCTS\VitoPractice\70-528\Practice70515\C08_Programming_the_Web_Application\WebForm2.aspx | | QUERY_STRING | | | REMOTE_ADDR | ::1 | | REMOTE_HOST | ::1 | | REMOTE_PORT | | | REMOTE_USER | VITO-2011W7\Administrator | | REQUEST_METHOD | POST | | SCRIPT_NAME | /C08_Programming_the_Web_Application/WebForm2.aspx | | SERVER_NAME | localhost | | SERVER_PORT | 60755 | | SERVER_PORT_SECURE | 0 | | SERVER_PROTOCOL | HTTP/1.1 | | SERVER_SOFTWARE | | | URL | /C08_Programming_the_Web_Application/WebForm2.aspx | | | 取得 Web 伺服器變數的集合。 |
TotalBytes | 429 | |
Url | http://localhost:60755/C08_Programming_the_Web_Application/WebForm2.aspx | 目前要求的 URL 資訊。 |
UrlReferrer | http://localhost:60755/C08_Programming_the_Web_Application/WebForm2.aspx | 前一個要求之 UR 資訊。L |
UserAgent | Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; NP06) | 取得用戶端瀏覽器的字串資訊 |
UserHostAddress | ::1 | |
UserHostName | ::1 | |
UserLanguages | System.String[] | |
Server
Context 物件
The Page.Context property is an HttpContext object that provides access to a variety of objects related to the HTTP request and response. Many of these objects are redundant, providing access to Page members including Cache, Request, Response, Server, and Session. However, the Context object includes several unique methods:
Context 方法
Context 屬性
Browser
取得瀏覽器相關的資訊
Request.Browser 的方法
Request.Browser 的屬性
Page.Header
沒有留言:
張貼留言