How to use custom HttpHandler with asp.net mvc in iis 7 and visual studio?
I have created a HttpHandler
that I would like to use with my asp.net mvc application (the version of mvc is not relevant). How do I make my HttpHandler
to handle request to a certain directory? The actual file in the directory doesn't exist, but that is fine since I want to create the response. I want it to work in IIS 7 of course, but also in Visual studio for debugging purpose. When searching the internet for it I found that you register handlers in web.config under the system.webServer
node like:
<system.webServer>
<handlers>
<add name="MyHandler" path="/MyPath/*" verb="*" 开发者_C百科type="Namespace.To.MyHandler" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
But my handler doesn't get fired.
Ok, so it turned out that this is not what I want to do at all. What I ended up doing was creating my custom IRouteHandler
and mapped a route to the folder I wanted my handler to use. My custom IRouteHandler
only created a new instance of my already existing IHttpHandler
, since I could use the same one. I will provide more info here later on.
精彩评论