Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to disable SSL for website

I created a website and deployed it to Windows Azure. Somewhere during development I enabled SSL from the project properties and everything (https address) was working fine in localhost and on the Azure website where I deployed my site.

Now my Azure trial is expiring and I am moving my website to another free asp.net hosting that does not support SSL without paying for it.

So I'm thinking it is going to be easy, just set SSL Enabled back to False as it was when I first started development and everything is fine, but that is not the case.

My website refuses to work after I disabled SSL. Picture of my Visual Studio setting with IIS Express opened and showing that there is a server on the right address: http://db.tt/EKTcxPsd

When I launch the site from Visual Studio it starts loading the page localhost:44300. After a few seconds I am redirected to https://localhost that displays a "webpage is not available" error. Picture: http://db.tt/VntZTpKD

I have tried deleting the IISExpress folder and relaunching visual studio. The recreated applicationhost.config file has the correct information (as far as I know)

<site name="PrototypeNew-bootstrap3" id="2">
  <application path="/" applicationPool="Clr4IntegratedAppPool">
    <virtualDirectory path="/" physicalPath="E:\path-shortened\Visual Studio 2013\Projects\PrototypeNew\PrototypeNew-branch" />
  </application>
  <bindings>
    <binding protocol="http" bindingInformation="*:44300:localhost" />
  </bindings>
</site>

I have the same problem after publishing the website to a hosting environment. Going to http://mywebsite.com redirects me to https://mywebsite.com and shows the same error as the localhost page.

If I re-enable SSL then the https address on my localhost starts working fine.

Does anyone know what is going on here? Is there another SSL switch somewhere that I forgot to turn off? Why is it always redirecting me to https

EDIT. Tried creating a new asp.net mvc 4 project. Launched it and it was working fine. Copied the web.config to my project and it was still redirecting to https:localhost

like image 231
JoonasL Avatar asked Aug 20 '13 14:08

JoonasL


1 Answers

Okay I finally found the solution. FilterConfig.cs looked like the following:

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
        filters.Add(new System.Web.Mvc.AuthorizeAttribute());
        filters.Add(new RequireHttpsAttribute()); // problem
    }

It must have automatically added the RequireHttpsAttribute when I enabled SSL and then didn't remove it. Removing it manually fixed the problem.

like image 99
JoonasL Avatar answered Nov 17 '22 03:11

JoonasL