on a .NET website, what's the best way of redirecting html pages to http if someone tries to access them by https?
I'm redirecting aspx pages using Global.asax but that doesn't pick up html pages...
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
IIS can be configured to do the redirects itself, if possible this will be the best approach.
Another approach would be to continue to use your redirect in Global.asax but configure IIS to send more requests, including requests for .html files to the .net run time. You should be able to do this on a website by website basis. You can then create an HttpHandler which will have the code to do the redirecting. This can be configured in the web.config by adding a line like
<httpHandlers> <add verb="*" path="*.html" type="You.Namespace.Handlers.RedirectHandler"/> <add verb="*" path="*.htm" type="You.Namespace.Handlers.RedirectHandler"/> ... </httpHandlers>
Only use this approach if all of this IIS site (https://example.com) is a redirect.
If you serve real .html pages through .net runtime you will have a performance cost.
Hope that helps.