Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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...


share|improve this question

migrated from Jun 7 '12 at 10:17

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

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

   <add verb="*" path="*.html" type="You.Namespace.Handlers.RedirectHandler"/>
   <add verb="*" path="*.htm" type="You.Namespace.Handlers.RedirectHandler"/>

Only use this approach if all of this IIS site ( is a redirect.

If you serve real .html pages through .net runtime you will have a performance cost.

Hope that helps.

share|improve this answer
I managed to map the html files to the ASP.NET ISAPI extension (Aspnet_isapi.dll) using IIS. This generates an entry under <system.webServer>. But how do I link it to the <httpHandlers> section ?? – user441365 Jun 6 '12 at 14:54

Try using javascript

<script type="text/javascript">
function LeaveHTTPS() 
        var newURL=window.location.replace("https","http");
windows.onload= function() {LeaveHTTPS()}
share|improve this answer
it needs to be tested though... will have to do minor modifications i guess – Sirwani Jun 6 '12 at 13:46
Thanks but I would rather use something more robust – user441365 Jun 6 '12 at 13:47
You would then need to create a file for every existing .html in the site with this redirect. Also the http redirects can provide much more information to search engins, proxies, caches, browsers e.g. 301, 302, 303, 304, 305, and 307. In this case the best response would be 301 Moved Permanently. – David Waters Jun 6 '12 at 14:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.