ASP. NET (get and post comparison)

Source: Internet
Author: User
ASP. NET (get and post comparison)

First, let's review the previously learned HTTP protocol.

There is a connection here. The Browser needs to request the server to create a connection. After the connection, it sends a request and the server responds. after the response is complete, close the connection. When http1.0 is used, it is a short connection and http1.1 is a long connection. A persistent connection means waiting for a very short period of time. If there are still requests, the connection will not be closed; otherwise, the connection will be closed.

Because of this connection, after the response ends, both the persistent connection and the short connection will be closed. When the connection is closed, the server does not know the existence of the browser because of this feature,HTTP is stateless. Stateless can cause us a lot of trouble. What is stateless is that the server does not remember that the browser once requested me. Therefore, when an external JS, CSS, and jpg files are requested on the same page, some data must be submitted repeatedly.

If multiple external files are referenced in a webpage, each file must send a request. There is also the relationship between the server and the browser: Request-response.

Will the server send a response to the browser?

No, because the server does not know which browsers exist. For example, Sina Weibo seems to have sent a response from the server to the browser.

How is this implemented?

The server does not actively send a response to the browser, and the browser has a timer to continuously send requests to the server to obtain the server's response. You need to use additional technologies such as serverpush (Ajax requests the latest data from the server over a period of time.

How is resumable data transfer implemented in Thunder?

When downloading, it records the number of bytes. And put all the bytes in the temporary file. The next download starts from the location of the byte recorded last time and stores it in a temporary file. Until the entire file is downloaded. Restore the file.

Today we want to learn general processingProgram, HTML controls and. net internal objects.

1. Objective: To introduce the operating mechanism of ASP. net from the network perspective, and analyze several core objects in ASP. NET.

2. Test results: familiar with general processing procedures for adding, deleting, modifying, and querying a single table

Next we will review what we have learned before. What is a browser language?

The language executed on the browser is called the browser language.

The server language is the language that is executed on the server.

What is the difference between static pages and dynamic pages?

Dynamic Pages need to run the server language, and static pages are displayed only. The Static Page Server reads the file directly and sends it directly after reading the file. It does not perform complex tasks on the server.

If it is a dynamic page, you need to create the class object on the server and call the correspondingCodeRun.

Previously, we wrote a Web server by ourselves, and we did not write the server for actual applications. After the website is developed, the website will be deployed on IIS.

Next, let's take a look at the IIS web server workflow.

The working principle of IIS is similar to that of the server we write.

Let's take a look at iis:

1. Check the IIS software.

In XP, IIS is 5.1, while in win7 is 6.0. The interface is slightly different.

 

Ii. Website running by ISS

We can create a virtual directory to publish some websites.

Demonstrate how to install IIS In win7.

1. Install IIS first. Open the control panel, find "programs and functions", and click in.

 

3. Procedures and functions

2. Click "enable or disable windows" on the left"

 

4. enable or disable the WINDOWS function

3. Find "Internet Information Service" and check it.

 

5. Find "Internet Information Service"

Wait until installation is complete

 

6. Wait until installation is complete

4. After the installation is complete, go back to the control panel, find "Management Tools", and click to enter

 

VII. Management Tools

5. Double-click "Internet Information Service (IIS) manager" to become IIS. If you need to use IIS frequently, you are advised to move your cursor to "Internet Information Service (IIS) manager" and Right-click and choose "send to" desktop shortcut to access IIS from the desktop, instead of clicking control panel every time.

 

8. IIS Interface

IIS interface:

5. Select "Default web site" and double-click "asp" in the middle"

 

IX. Double-click ASP

Change "enable parent path" to "true"

 

10. Change the Enable parent path to true.

7. Configure the site. Click "Advanced Settings" on the right"

 

11. "Advanced Settings"

Select the directory of your website

 

12. Select the website directory

8. Return to IIS, click "Bind..." on the right, select the website you want to bind, and click "edit"

 

13. Select a website and click Edit.

If you are using a computer, you only need to modify the following port number. You can modify the number at will. If it is an office LAN, click the drop-down box and select the lan ip address on your computer, for example, 192. 168. **. **, and then modify the port number.

 

14. Modify the port number

9. Return to IIS. If it is stopped on the right, select start and Click Browse website below to open the website in the folder you are bound.

 

15. browse the website

10. If you have multiple websites, right-click "website" on the left side of IIS and choose "add Website"

 

16. Add a website

Modify the "website name", "physical path", and "Port" in three locations. If the LAN is used, modify the "ip address", as shown in the preceding figure.

 

17. Modification content

11. After adding the website, click the name of the newly created website, which is the details of the website.

Next, let's take a look at how IIS works,

18. click Configuration

 

19. aspnet_isapi.dll

ASP and aspx are different. ASP is handed over to ASP. dll.

 

20. asp is handed over to another person for processing

Static request page:

Internally, the system first processes the request message, the Request Path of the request message, and then reads the file. After reading IIS, IIS generates a Response Header for the response and sends the file to the browser.

 

Request dynamic page:

The browser sends a request and uses the suffix to determine whether the request is static or dynamic? If the suffix is aspx, IIS cannot handle it at this time. However, find someone to handle the issue. Where is the link configured?

 

After a request is sent, both static and dynamic pages are searched in the ing table. It's just a problem. If it is a static page, it will also find it in the ing table. If it is not found, IIS will handle it by itself. Read the file and return it. If the suffix is aspx and is found in the ing table, the request is sent to the aspnet_isapi.dll program, which is framework. This file is available only after the. NET Framework is installed.

So what about IIS dependency on. NET Framework? IIS runs directly on the operating system. IIS does not depend on. NET Framework and has no relationship with. NET Framework. C # code is executed on. NET Framework. IIS transfers the request to. NET Framework and allows. NET Framework to execute the C # code of the page. ISAPI is the relationship between them. How to execute the requested Class Object and create the class object through reflection. After the method is executed, it is returned layer by layer. Finally, return to the browser.

When I have just installed the operating system and configured IIS, can I execute a website written by Asp.net? No, no. NET Framework

If I have installed the operating system, the. NET Framework, IIS, and an Asp.net website on IIS. Can it run? No. At this time, IIS does not know the existence of. NET Framework. No configuration. You need to configure the command: run the command: cmd.

The aspnet_regiis-i registers the. NET Framework in IIS to generate what we see. You cannot run it here. Because this command is in the. NET Framework installation directory.

Open the command prompt for vs2010.

 

21. cannot be executed here

 

22. Command Prompt for enabling vs2010

 

23. Run the following command here:

 

24. IIS running process diagram

 

25. Workflow

After the request is sent, if the suffix is aspx and iis5.1 is IIS installed in Windows XP, the request is sent directly to IIS. This process does not exist. This figure shows the execution process after iis6.0. In Windows sever2003, 6.0 is installed, and ISS after 6.0 is requested. After the request comes over, this request does not reach IIS. The first step is not through IIS. First go through HTTP. sys, a system-level driver. Operating system kernel program. Receive the request first. filter the request message to see if the request message is valid? If the request is valid, the driver sends the request to IIS. IIS then finds the IIS extension, including aspnet_isapl.dll and aspnet_filter.dll. The two extensions do different things.

If it is a static page, it is processed directly. If it is aspx, it is handed to the center. If it is ASP, it is handed to the right.

Next let's talk about ASP. NET.

Is ASP. NET a language? No, it is a dynamic web page technology, just like ASP.

What is the difference between ASP. NET and ASP?

Some of their internal objects are the same, because both of these technologies are Microsoft and both are dynamic web page development technologies. The server-side scripting language used when ASP is used to develop dynamic web pages. The script language is interpreted and executed. Both C # and Java are compiled and executed. ASP. NET relies on the. NET Framework framework.

 

We need to learn these three parts when learning ASP. NET. ASP. NET: general processing program (ashx), webform (aspx), MVC (model, view, controler ).

 

Let's take a look at today's highlights:

 

26. Common ASP. NET files

Now we only need to remember the first three.

Next we will write a general processing program to create a new website:

 

27. Create a website

 

28. Create an empty website

If I shut down vs, how can I open the website after it is closed? I sent my website to someone else. How can I open it? File-open-website. A simple method:

 

29. Save as Solution

You can directly find the saved folder and double-click the solution to open the website.

Next we will create a general processing program:

 

30. Add a new project

 

. Create a general processing program

Ashx is a class. Why does it become a general processing program instead of a class? Because it implements the ihttphandler interface.

 

General processing procedures

 

33. Go to definition

Processrequest is used to process and respond to requests.

The ihttphandler interface is used to ensure that all classes that can process browser requests have this method. This is the role of this interface.

 

34. httpcontext

 

35. Execute the server code

 

36. Content-Type

If HTML code is output, convert it to text/html

Httpwatch_pro_6.1.46:

Httpwatch_pro_7.1.37:

Exercise:

Output an HTML page containing an image.

37. Output HTML page code containing images

 

38. Two requests were sent

 

39. The HTML code is returned.

 

Send a request again to request an image

 

Things the server helps us do

Next let's change this code.

 

Forty-two, plain text, how to run?

 

Forty-three, plain text displays plain text

 

Httphandler ):Is a special class that implements the system. Web. ihttphandler Interface.
Any class that implements the ihttphandler InterfaceIs used asPrerequisites for the target program of the external request. (Any class that does not implement this interface cannot be requested by the browser.)

It is called and started to run by servers that support ASP. NET. An httphandler program is responsible for processing the correspondingOne or more groupsThe access request of the URL address, and receive the access request information (Request Message) sent by the client and the response content (Response Message ).

Simply put: you can create an httphandler program to generate the browser code and send it back to the client browser.

The httphandler program can complete most of the tasks that can be completed by common class programs:
1. Obtain the data and URL parameters submitted by the client through the HTML form
2. Create Response Message content for the client
3. access the file system on the server
4. Connect to the database and develop database-based applications
5. Call other classes

 

Forty-four, Web Server

 

45. General processing procedures

 

46. How does the server receive and send data?

 

47. What needs to be mastered today

Let's take a look at the two data submission methods in the browser, taking Baidu as an example:

 

On the 48 th day, Baidu used URL-based parameters for search.

 

Forty-nine, submit data through form

In this way, the URL transmits the parameter http: // 127.0.0.1/login. ashx? Txtname1 = Jordan & txtpwd1 = 123

Let's write down the GET request,

 

50. receive data

There is also a text box that simulates Baidu search and creates a text box.

. Write an HTML page to simulate Baidu's passing parameters through URL

 

. Receive URLs in the general processing program

 

. Execution Process

Fifty-four, multiple execution request values

 

Fifty-five, get the value of the text box and pass the value

 

Fifty-six, monitoring execution process

 

May 17. Check whether the write can be submitted.

Nothing is found after running, so it is not submitted to the server at all.

 

Fifty-eight.

 

Fifty-nine. In this case, submit through get.

Next let's take a look at how to transmit data through post.

Page for form submission

 

. Name two text boxes

 

. Get data on the server

 

63. Execution Result demonstration

Next, let's take a look at the differences between GET requests and post requests.

Post is more content than GET request packets

Content-Type: Application/X-WWW-form-urlencodedThe data format transmitted to you by the server is the same as the URL. In addition, content-type is required for post submission. If no content is available, post submission fails.

Cache-control: No-CacheIt is to tell the server that the browser does not cache your page.

Request body name = 123 & Pwd = ABC

 

14th. Pay attention to this setting.

Next, let's take a look at common request members.

 

Request

Next, let's take a look at what Params can get?

 

16th. traverse the output to see what is in it.

 

17th. What can Params get?

Context. request [""] can be written in this way, but it is not recommended. // Equivalent to context. Request. Params

Next let's take a look at response.

 

18th, response

 

Sixty-nine, redirect

Hello world output? Monitor the request.

 

70. Requests monitored

 

. Redirect Execution Process Diagram

 

The execution will not be performed any more.

Next, let's take a look at the Post issues that need attention.

 

. Post is not allowed in this case

There cannot be multiple forms on the page. Yes, and there is no conflict.

Because each form has an action.

Who must have the name attribute to submit.

Can I submit the button to the server? If you add a name to the server, submit it to the server.

Only value can be submitted to the server.

Div cannot be submitted to the server.

Only form elements can be submitted to the server.

When an element is disabled, It is not submitted to the server.

 

14th. Submit gender

 

Select WHO to submit

 

16th. Multiple selections for form submission

 

77. Multiple monitoring submissions

Use the server to receive the message.

 

. Receive it on the server

 

. Obtained value

If I have multiple text boxes with the same name, what should I do at this time?

The following shows how to use multiple text boxes:

 

80. When multiple text boxes are monitored

Next, we will simulate login. Please pay attention to it !!!

Back to start position

 

Author's recentArticleList:

C # intermediate advanced tutorial (completely free, the best gift for code lovers. Note: I have shared my carefully-organized C # intermediate advanced tutorial without any commercial purpose. I hope to share my experiences with more code lovers. Please give me more advice !!!)
Asp.net Project Library mall project overview
Layer 3 and other content Recursion
Layer 3 (1)
Layer-3 cases (and Common Errors)
Layer-3 instances (SQL crud)
Handwritten Code Generator
SQL database ado.net Database Application diagram 1
Database Application details 2
Ado. Net (connotation efficiency problem)
Ado. Net example tutorial 1
Ado. Net example tutorial 2
Database Application details 3
Ado. Net (including stored procedures)
Process-oriented, object-oriented, and advanced Process-oriented, object-oriented in-depth understanding 1
Process-oriented, object-oriented in-depth understanding 2
Object-oriented deep understanding 3
Regular Expression
Ubiquitous XML
Winform Basics Winform Basics
Commonly used controls in winform
Process-oriented Comparison of three cycles
Method (I) in C)
Our common Array
Object-oriented Thought Change
C # super-class and easy-to-use classes
The use of destructor and namespaces in C #
C # super-class and easy-to-use strings
How to quickly process strings in C #
Value Type, reference type, and others
Arraylist and hashtable
Arraylist and hashtable
File Management
Polymorphism
Section on other issues in C #
GDI + The GDI + code I have collected over the years
The GDI + Code 2 I collected over the years
HTML overview and CSS HTML language that you cannot ignore
You can't ignore HTML 2.
HTML language 3 that you cannot ignore
HTML-Comprehensive
CSS basic content-special contribution to the Mid-Autumn Festival
CSS basic content 2
Javascript Basics Javascript basics 1
Javascript basic 2 Javascript DOM Programming
Jquery Jquery (connotation: jquery selector)
Jquery Example 1

 

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.