Benefits of General Handler Ashx

Source: Internet
Author: User

"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

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.