ASP. NET Web Pages-object, asp. netpages
Web Pages are usually related to objects.
Page Object
You have seen some used Page objects:
@RenderPage("header.cshtml")@RenderBody()
In the previous chapter, you have seen two used Page Object Attributes (isPost and Request ):
If (isPost) {if (Request["Choice"] != null {
Page Object Methods
Method |
Description |
Href |
Build a URL with the specified parameters. |
RenderBody () |
In the layout page, the content page section is not in the specified part. |
RenderPage (page) |
The content of a page is displayed on another page. |
RenderSection (section) |
The specified content is displayed on the layout page. |
Write (object) |
Write the specified object as an HTML-encoded string. |
WriteLiteral |
The specified object can be written without HTML encoding. |
Page Object Attributes
Attribute |
Description |
IsPost |
Returns a value (true or false) indicating whether the HTTP data transmission method used by the client to request a webpage is a POST request. |
Layout |
Gets or sets the path of the layout page. |
Page |
Provides access to similar attributes of page data shared between pages, layout pages, and pages. |
Request |
Obtain the HttpRequest object of the current HTTP request. |
Server |
Obtain the HttpServerUtility object. The method provided by this object can be used during webpage processing. |
Page attribute (of the Page Object)
The Page attribute of the Page object, which provides access to similar attributes of Page data shared between pages, layout pages, and pages.
You can add (use) your own attributes like Page attributes:
- Page. Title
- Page. Version
- Page. anythingyoulike
The Page attribute is useful. For example, you can set the page title in the Content File and use it in the layout file:
Home. cshtml
@{Layout="~/Shared/Layout.cshtml";Page.Title="Home Page"}Layout. cshtml
<!DOCTYPE html>