Starting from this section, we began to contact General processing programs. General processing programs are the most efficient and the execution process is the simplest, but their principles are very important, once we have learned the general processing program, it is quite easy to learn webform again, and it can be achieved almost quickly.
When we add a general handler in Visual Studio 2010, a file with the ashx extension is generated. The code in the file is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<% @ Webhandler Language = "C #" class = "first" %> Using system; Using system. Web; Public class first: ihttphandler {
Public void processrequest (httpcontext context ){ Context. response. contenttype = "text/plain "; Context. response. Write ("Hello World "); }
Public bool isreusable { Get { Return false; } } } |
From the above code, we can find that the general processing program is a class that implements the ihttphandler interface. It can be executed on the server side, and data can be obtained from the browser or sent to the browser, so what do the above Code represent?
The processrequest (httpcontext context) method is called when a program is accessed. The parameter is the object of the request context, and information can be processed through the object. response. write ("Hello World") is a method that outputs data to the browser from the server.
So what happens to the general processing program? How did he send data to the browser through the server? See:
It's just a simple process of simulating a user's access to the Internet through a general processing program. You may seem to understand that accessing the Internet is also a thing on a computer, it's just this computer. Your ordinary home computer is a little more powerful. You already have a general process of surfing the Internet. This figure requires a good understanding, only in this way can we know what problems will occur in the future development process, and make users enjoy surfing the Internet better, as long as a user visits your website for the first time, he will be admitted to your website.
In fact, the processing process of aspx and MVC is not complicated, but it is more complicated on the server side. However, ashx is their basis and a top priority, if ashx is good at learning, aspx can be self-taught. You can read any book on your own, and it is easy to understand MVC. Therefore, ashx must be good at learning, we will introduce ashx in a large amount in the future. Thank you!