We'll create a new project and write our first middleware. We can observe the execution mechanism of middleware with this project.
- First, let's watch the anatomy of an HTTP handler:
public class MyHttpHandler : IHttpHandler { public bool IsReusable { get { return false; } } public void ProcessRequest(HttpContext context) { context.Response.Write("This page pass by MyHttpHandler <br />"); } }
- Now, let's see the Web.config configuration:
<system.webServer> <handlers> <add name="MyReportHandler" verb="*" path="*.report" type="MyApp.HttpHandlers.MyReportHandler" resourceType="Unspecified" /> </handlers> </system.webServer>
We had to specify a name, the authorized HTTP verbs for this Handler, the path, which is the named ...