Axd format files, whether in asp.net or now developing asp.net MVC applications, are preferred by Insus. NET.
Because we can Virtualize a file that does not exist in the application. In fact, the file in this format is Handler, which implements the IHttpHandler interface. Therefore, you can create an axd to replace the ashx file.
The following example shows how to create, configure, and apply an ASP. net mvc application in Insus. NET.
In the Handlers directory, create a cs class named Axd. cs. This class name only complies with the naming rules of the C # class.
The main point of this class is to implement the IHttpHandler interface.
The Axd is created, but it cannot be used directly. It also needs to be configured in Web. config:
Under the handlers subnode under the System. webServer node,
Add:
Mark 1 to specify a name.
Mark 2. This is the key point. The external name is a file name that can be seen during user access. But you can define it as the same as the class name you created above. However, Insus. NET is used to use a name different from the class name.
Mark 3, which is the full name of the class, including the namespace.
At this point, we can test it, but before testing, we also need to check your route Configuration:
In the address bar of the browser, enter http: // localhost: 50369/I. axd? V = leo. Pay attention to the highlighted syntax.
For more in-depth demonstration, create an operation on the MVC controller:
Create a view:
Real-time operation Demonstration: