Recently, I am going to learn ASP. NET. I have read some video tutorials on the Internet at the early stage, and I am going to organize my learning items for reference later.
This article uses html and ashx to implement aspx, achieving the simplest dynamic web page effect. The development environment is VS2012. The Demo structure is as follows:
The aspx file is a Microsoft dynamic web page file running on the server. After being parsed and executed through IIS, you can get a dynamic page, which includes the aspx file and aspx. cs file, as shown in. One is used to control the foreground, and the other is to control the background. The classes in the aspx. cs file Inherit System. Web. UI. Page, while the Page class implements the IHttpHandler interface. We know that classes in the ashx. cs file also implement IHttpHandler. Aspx only goes through some more complex processing. It achieves the same effect as implementing dynamic pages with ashx and html. The following shows a TextBox and a Button, which respectively display the interaction between the client and the server in two ways.
Specific implementation process:
1. Use aspx:
The index. aspx code is as follows:
Index. aspx
The index. aspx. cs code is as follows:
Page_Load (button#click (str = Response. Write (+}Index. aspx. cs
2. html + ashx:
The code for index.html is as follows:
Index.html
The server. ashx code is as follows:
Context. Response. ContentType = str = context. Request [context. Response. Write (+ fullPath = context. Server. MapPath (content =}Server. ashx
Enter "snail Il" in the TextBox and click "Send request". The results are as follows:
It can be seen that the effects of html + ashx and aspx are basically the same. The only difference is that after the aspx implementation example sends a request, the TextBox value can still be seen. The value in the text box after the request is sent in html + ashx is empty because the initial value of the re-drawn text box in the ProcessRequest method in ashx is empty. In fact, the essence of aspx is implemented through html + ashx, but Microsoft encapsulates it.