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...
migrated from stackoverflow.com Jun 7 '12 at 10:17
This question came from our site for professional and enthusiast programmers.
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
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.