ASP. NET notes,

Source: Internet
Author: User

ASP. NET notes,

Dynamic Web page and B/S Technology

Interaction with users can be implemented by different people at different times.

Cji asp php aspx asp. NET (MVC)

C/S) b/S (you only need to have a browser deployed on the Web server to upgrade the server)

In the B/S structure, the browser and the server use the request/response mode for interaction (the request sent by the client is called a request)

Response from the server to the client

HttpProtocol

Request/response processing mode

HttpCommunication Protocol features

Transient connection: the network is disconnected immediately after communication;

Stateless. For the server, every request is brand new;

It can carry a variety of data content, such as webpages, images, audios, and videos;

It is a plaintext data transmission protocol and is not secure.

(From the server perspective)

No client sends a request to the server. The server cannot send a response.

After the communication between the server and the client is completed, the connection will be disconnected. The next communication will fail to distinguish the client.

On the server side, only one client can have an infinite number of connections, which belong to a one-to-many relationship.

(From the client perspective)

To receive data from the server, the client must initiate a request first.

In order for the server to be able to distinguish, you must actively tell the server.

HhtpCommunication protocol details

Uniform URL resource Descriptor (Uniform Resource Locator)

Host Name on the Network (you can replace it with an IP address) [: port] (port Number) [path] (path)

Get (Request Method) (plaintext transmission (quantity limit)/post data package transfer no size limit

HttpStatus Code

Response status code (200 successful)

3 indicates redirection

4 indicates a request error.

404 not found

An error occurred while starting with 5 or 6.

505 Protocol version not supported

MIMEType

Each MIME type consists of two parts. The preceding part is the big data category and the specific type is defined later.

The data types improved by the server to the client are controlled by the mime type.

ASP. NET is a technology used to create dynamic websites.

ASP. NET is an event-driven, control-based architecture.

ASP. NET has been compiled twice

IIS

ASP. NET engine (Environment)

The first time a page class is generated, the second time the page class is not directly instantiated.

System. Web. UI. Page class (Page class)

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Page name. aspx. cs" Inherits = "Class Name" %> (Page command)

Init (during page initialization)

Load (when loading the Page) (Page. IsPostback (judge whether it is loaded for the first time ))

PreRender (before page display)

Unload (when the page is uninstalled)

ASP. NETCommon built-in objects in

Page Object pointing to the Page itself, with the scope of the Page execution period

The Request object reads the value sent by the merchant during the Web Request.

The Response object encapsulates the output returned to the http client during the page execution period

The Application object represents the State object that the current Application acts on throughout the running period.

Session object state persistence object for tracking sessions of a single user (stored on the server)

One way for Cookie object client to maintain session information (stored on a browser (session Cookie ))

The Server object provides access to methods and properties on the Server.

Request. QueryString can be used to obtain data transmitted through the URL path.

Request. From obtains the data submitted for transfer through commendation

You can use this property to obtain the content transmitted in the Request. Params method or above.

The default value of the webpage is string type.

Response. Redirect (Redirect to another page) (two requests)

Page Lifecycle(Configuration phase event processing phase display phase clearing phase)

The Server object is the calcium supplement of the HttpServerUtility class, including the method for processing web requests.

The Execute method and the Transfer method both stop the execution of the current page and forward the execution of the URL specified by the user in the method, at the same time, the user's session status and any current transaction processing status will be transmitted to the new page

Differences:

Server. Execute (the content of other pages can be embedded in the current page) (the control is relatively transferred, and the control is returned to this page again for subsequent event processing)

Server. transfer, is the absolute transfer of control, data can be transferred during the transfer, the URL address remains unchanged) (is the absolute transfer of control within the server, it is transparent to the outside, do not feel, is a request, the URL address remains unchanged)

Response. Redirect (gfir redirection of the customer, is to discard the original request data, re-open the new request, the URL address will change)

Default transmission mode of Html form GET Server Control default transmission mode POST

Server. HtmlEncode (automatically transcoded to Html)

Server. HtmlDecode (automatic decoding)

Server. UrlEncode (contains special characters that can be transcoded using)

Server. UrlDecode ()

The protected class can be used in front-end encoding.

<% = %> (Indicating the value of the output background)

Server. MapPath

~ /Represents the virtual root directory of the outlet

Status Management

Status indicates the information that any type of data can remain active for a period of time.

This period can be the entire application lifecycle, the time when the user uses the application, or the time before the user browses another page.

Status management is the process in which you maintain the page information for multiple requests on the same page or different pages.

Http (hypertext transfer protocol): hypertext transfer protocol (application layer protocol) (does not record user information)

What does post get head options delete trace put (Request Method) do?

By default, browsers use GET forms, preferably POST.

The size of GET data cannot exceed 1 kb of POST data.

According to the location of the storage status, status persistence in ASP. NET is classified as follows:

Server side; Application (accessible to all users) and Session (Session state holding object: Close the browser Session to end (maximum inactivity Duration: minutes by default ))

Window: Cookie (), ViewState, query string, hidden form field (hidden field)

Session

Sessoin. Clear (); Clear Session

Session. Abandon (); terminate the Session

Cookie

The maximum size is 4 kb stored in the client browser or client hard disk.

Retain the personal information of the client in the Client System

Session Cookie(Any session Cookie will be lost after the browser is temporarily closed)

Persistent Cookie(The Cookie expiration time needs to be set when it is saved on the client's hard disk)

CookieDisadvantages: No security assurance is provided, controlled by the client system; limited capacity; up to 20 browsers can be accommodated

Eg:

HttpCookie = new HttpCookie ("cookie name", "value ");

Cookie. Expires (expiration time (persistent Cookie after this attribute is set) = DataTime. Now. AddMonths (1 );

Response. Cookies. Add (cookie );

Read: Requset. Cookies ["cookie (name)"]. value; (the invalid value is null)

App_Code (the created class and interface should be placed under this folder)

ViewState (view State) (valid on the current Page) (the current Page is used in the same way as the Session) (<% @ Page ViewStateEncryptionMode = "Always" %>)

ApplicationIndicates an ASP. NET application instance.

The status consists of all methods and sets of the HttpApplicationState class and various customs.

When the first user requests an ASP. NET file, it will apply and create an Application Object

It can be used throughout the application, and the created object will continue until the application is closed. It is an application-level variable and can be used on all pages.

The Application object stores data with key/value pairs

Global. asax(Global Application class)

Application_Start (application startup) Application_End (Application closed) Application_Error (unprocessed error) Session_Start (session started) Session_End (session ended)

ASP. NETWidget(HTML controls and Web server controls)

The Web server control is located in the namespace of System. Web. UI. Webcontrols.

Literal control Repeater

Whether the AutoPostBack attribute of the TextBox Control is automatically uploaded to the server (TextMode)

RequireFieldValidator control ControlToValidate attribute (ID of the control to be verified) (add key = "ValidationSettings: UnobtrusiveValidationMode" value = "None"/>)

Regular Expression: "+" indicates that at least one character (Group) appears. [any character (any one) can appear.]? Is 0 to 1 * is 0 to n times

Master page: The Role of unified style (Cannot Use output Cache)

Cache:It is a technology widely used in computing to improve performance. It keeps data with high access frequency or high construction costs in the memory and is used multiple times without re-creation.

ASP. NETTwo types of cache are supported:Output cache data cache

<% @ OutputCache Duration (the cache time is measured in seconds) VaryByParam = "none" (not cached based on parameters) VaryByControl = "Control name" (cached based on control name) %>

Data Cache: Cache (Cache class) (also stores key-value pairs)

Shared = "true"

User Control (. ascx )(You can use the output cache.) (<% @ Control %>) (define the association of background Code) (<% @ Register %>) (Register a user Control)

Code required for data binding by DataBind ()

Ajax Asynchronous JavaScript and XML

$. Ajax ({

Type: "POST ",

ContentType: "application/json; charset = UTF-8"

});

HttpContext (representing a context of the current request)

IIS processing is based on the file suffix

ISAPI application (in fact, it is only an interface that acts as a proxy. The main task is to map the requested page (File) and the actual processing program corresponding to the suffix)

Handler ing

The HttpRuntime class is a major entry of asp.net to process requests.

Application domain AppDomain

HTTP. sys built-in driver to listen for HTTP requests from outside

All applications in MySQL 5.0 are in the process of aspnet_wp.exe.

Iis6 w3wp.exe

HttpModule can be used to perform tasks before a specific task is executed.

HttpHandler is also the bottom layer of http request processing.

HttpModule implements System. web. class of the IhttpModule interface (essentially a filter (filtering requests and responses) (having the permission to access the HttpContext object, modifying requests, outputting response content, and providing custom authentication) (provide response pre-processing and response post-processing for each request) (multiple httpmodules can hook the order in which the same event events are processed in the web. configuration order in config)

 

 

To use HttpModule for permission management, follow these steps:

1. Define a class Qx to implement the System. Web. IhttpModule Interface

2. Implement the Init method in the interface to process the context. AcquireRequestState event, intercept user requests, and determine whether the user has the permission to access specific resources.

3. Add the configuration of the HttpModule in web. config.

Application. CompleteRequest (terminate the current request );

Watermark

 

Global Handler

 

Mechine. config: Provides the default configuration for the entire machine. The personality of this file will affect all local sites.

Web. config: It is generally used for application-level configuration files. modifications to it do not affect other sites, but can also be used for subdirectories under sites.

Case Sensitive Based on XML

Readable and writable

You do not need to restart the server to modify the configuration.

Principles for configuring the latest application

Security Control: Identity Authentication (logon page) (whether to have the corresponding identity); permission control (control the permissions of users with various identities)

Authentication Method

Windows Authentication

Passport Authentication

Forms authentication

<Authentication mode = "Forms"> <forms name = "" loginUrl = "page" timeout = "60" protection = "All" (encrypted)> </forms> </authentication>

Authorization: allow (allowed) deny (deny) * (all users )? (Anonymous user)

<Authorization> <deny users = "?" /> <Allow roles = "username"/> <deny users = "*"/> </authorization>, execute the first matched Person)

System. Web. Security. FormsAuthentication. RedirectFromLoginPage (username, false) (create verification ticket)

Session. Clear ();

Session. Abandon ();

System. Web. Security. FormsAuthentication. SignOut ();

Response. Redirect (the page after exiting );

 

 

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.