"Eliminates the control parsing of normal. aspx pages and the process of page processing". This is the main one. Runs much faster than. aspx.
。 Ashx This file is especially useful for generating dynamic images, generating dynamic text, and so on.
HttpHandler and ASP. NET form comparison, the biggest advantage is the light weight.
HttpHandler mainly handles HTTP requests, ASP. NET forms are responsible for generating HTML pages in addition to processing HTTP requests, and adding a lot of callback logic to support server space.
Each has its own advantages and is flexible to use, for example, if you want to return a JSON data, HttpHandler is better.
Asp. NET form (Page) inherits from IHttpHandler and does some extensions.
General processing Program ASHX parsing
General handler Classes
public class Handler1:ihttphandler
public void ProcessRequest (HttpContext context) is a method that Handler1 must implement;
Where the parameter context belongs to the HttpContext type
Context. Response.ContentType = "Text/plain";
Context. Response.Write ("Hello World");
The HttpContext type has a property of response;
Public HttpResponse Response {get;} This property gets an object of type HttpResponse.
The HttpResponse type has the Write () method, which writes a string to the HTTP response output stream.
public void Write (string s);
HttpResponse types have contenttype properties:
public string ContentType {get; set;}
Benefits of General Handler Ashx