ASP. NET [3]-ashx

Source: Internet
Author: User
Tags visual studio 2010

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!

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.