Fold the code that processes file. ashx in general (# region)

Source: Internet
Author: User

Note: This method is used for website projects. However, it can be used as a reference for other types of projects. 1. Create a New ashx file, such as/System/xxx. ashx, where you want to be accessed by others. Create xxx. the ashx code is as follows: [csharp] <% @ WebHandler Language = "C #" Class = "xxx" %> using System; using System. web; public class xxx: IHttpHandler {public void ProcessRequest (HttpContext context) {context. response. contentType = "text/plain"; context. response. write ("Hello World");} public bool IsReusable {get {return false ;}} have you noticed that the Class in the first line is "xxx? "Xxx" represents a type, indicating that the processing logic of the general processing file is executed there. At this time, you should be a little curious. Can you set the Class attribute or move the "xxx" Class to another place? It is okay to tell you clearly. However, I found that for websites, placing the cs file in addition to the App_Code file cannot be identified. Therefore, a new xxx file is created in the App_Code file. cs, set xxx. the ashx Code except the first line [csharp] <% @ WebHandler Language = "C #" Class = "xxx" %> is cut to xxx. in cs, note that it is cut. Year, running normally.

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.