How to use Axd format files in asp.net MVC applications

Source: Internet
Author: User
Tags naming convention

Axd format files, whether in asp.net or now asp.net mvc applications, are insus.net more preferred to use.

Because we can virtual a file that does not exist in the application. In fact, this format of the file is also handler, it has implemented the IHttpHandler interface. So you can create a axd to replace the ashx file.

Below insus.net in the asp.net MVC application, give a simple example, create, configure, and apply.

In the handlers directory, create a CS class, tentatively called it Axd.cs. This class name conforms to the C # class naming convention only.

The most important place in this class is to implement Interface IHttpHandler. Axd is created, but it cannot be used directly, it is also configured in Web.config:

Under the System.webserver node under the Handlers sub node,

Add to:

<add name= "Axdhandler" verb= "Post,get,head" path= "I.axd" type= "Insus.NET.Handlers.Axd"/>

Mark 1, specify a name.

Mark 2, this is the key place, this foreign name will be accessed when the user can see a filename. But you can define the same as the class name you created above, and there's no problem. But insus.net habit, or instead of a name that is not the same as the class name. Tag 3, which is the full name of the class, including namespaces.

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.