Reputation: 101
We created our own redirect httpHandler that accepts all requests (verb="*", path="*"):
<system.webServer>
<handlers>
<remove name="Redirect" />
<add name="staticFileHandler" path="*.html" type="System.Web.StaticFileHandler" verb="GET,HEAD" />
<add name="Redirect" path="*" verb="*" type="RedirectModule.RedirectHandler,
RedirectModule, Version=1.0.0.0, Culture= neutral, publicKeyToken=77c8b6b494e19eeb" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
In the http handler we have code that checks the URL and redirects if the browser it is mobile. In this case if the browser is not mobile or we've already redirected we would like to continue with execution of the static files and display their content.
The problem we're having is that because the http handler we are using accepts all requests the StaticFileHandler doesn't process the HTML file and we always get a white screen.
How do we pass execution from the httphandler to a staticFileHandler through code or the web.config.
Appreciate any help.
Orit
Upvotes: 1
Views: 1430
Reputation: 20357
A handler should only decide how to process a file extension (either physical or logical), not when. I think you meant to create a module.
See this answer by Jon Galloway and this MSDN article on Handlers and Modules.
edit: Also, check out ASP.NET/Mobile's first How-To. It shows how to accomplish this in both Web Forms and MVC.
Upvotes: 3