Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET Web Pages Class Reference

ASP.NET Web Pages - Classes


ASP.NET Class Reference

Method Description
AsBool(), AsBool(true|false) Converts a string value to a Boolean (true/false). If the string cannot be converted to true/false, returns false or another specified value.
AsDateTime(), AsDateTime(value) Converts a string value to a date/time. Returns a DateTime. If the string cannot be converted to a date/time, returns MinValue or another specified value.
AsDecimal(), AsDecimal(value) Converts a string value to a decimal value. If the string cannot be converted to a decimal value, returns 0.0 or another specified value.
AsFloat(), AsFloat(value) Converts a string value to a float. If the string cannot be converted to a float, returns 0.0 or another specified value.
AsInt(), AsInt(value) Converts a string value to an integer. If the string cannot be converted to an integer, returns 0 or another specified value.
Href(path [, param1 [, param2]]) Creates a browser-compatible URL from a local file path with optional additional path parts.
Html.Raw(value) Renders value Renders as HTML markup, rather than as HTML-encoded output.
IsBool(), IsDateTime(), IsDecimal(), IsFloat(), IsInt() Returns true if the value can be converted from a string to the specified type.
IsEmpty() Returns true if the object or variable has no value.
IsPost Returns true if the request is POST. (The initial request is usually GET.)
Layout Specifies the path of the layout page to apply to this page.
PageData[key], PageData[index], Page Includes shared data among the current requested page, layout page, and partial pages. You can use dynamic pages to access the same data via properties.
RenderBody() (Layout pages) Renders the content of a content page that is not in any named sections.
RenderPage(path,* values*)
RenderPage(path[, param1 [, param2]]) Renders a content page using the specified path and optional extra data. You can get the extra parameter values from PageData via position (example 1) or key (example 2).
RenderSection(sectionName [, required = true|false]) (Layout pages) Renders a named content section. Set required to make a section required (non-optional).
Request.Cookies[key] Gets or sets the value of an HTTP cookie.
Request.Files[key] Gets the files uploaded in the current request.
Request.Form[key] Gets the data posted in the form (as a string). Both Request.Form and Request.QueryString require [key] to check.
Request.QueryString[key] Gets the data specified in the URL query string. Both Request.Form and Request.QueryString require [key] to check.
Request.Unvalidated(key)
Request.Unvalidated().QueryString|Form|Cookies|Headers[key] Optionally disables request validation (form elements, query string values, cookies, header values). Request validation is on by default, preventing users from submitting markup or other potentially dangerous content.
Response.AddHeader(name, * value*) Adds an HTTP server response header to the response.
Response.OutputCache(seconds * [, sliding] [, varyByParams]*) Caches the page output cache for the specified time. Set sliding to reset the access timeout for each page, and set varyByParams to cache a different version of the page for each different query string of the requested page.
Response.Redirect(path) Redirects the browser request to a new location.
Response.SetStatus(httpStatusCode) Sets the HTTP status code sent to the browser.
Response.WriteBinary(data [, mimetype]) Write data The content response's optional MIME type.
Response.WriteFile(file) Writes file content to the response.
@section(sectionName) { * content* } (Layout pages) Defines a named content section.
Server.HtmlDecode(htmlText) Decodes an HTML-encoded string.
Server.HtmlEncode(text) Encodes a string for rendering in HTML markup.
Server.MapPath(virtualPath) Returns the server's physical path for the specified virtual path.
Server.UrlDecode(urlText) Decodes URL text.
Server.UrlEncode(text) Encodes URL text.
Session[key] Gets or sets a value that persists until the user closes the browser.
ToString() Displays the value of an object represented as a string.
UrlData[index] Gets extra data from the URL (for example,/MyPage/ExtraData)。