nealkernohan
nealkernohan

Reputation: 836

http://localhost:port always redirecting to https://localhost

I'm building a simple website in vs2015. I have IIS express selected as the hosting environment. I have tried multiple new projects and seem to be going around in circles, having installed and uninstalled iis-express 10 multiple times, and added and removed windows feature of iis also. When I launch a web project from vs2015, it used to open (without issue) a http://localhost:port (e.g. http://localhost:51898), but now continually redirects to https://localhost.

Any idea why?

Upvotes: 8

Views: 25007

Answers (4)

OneGhana
OneGhana

Reputation: 117

in my case, it was a configuration i did on IIS for all my sites to load via https. The rewrite rule matched localhost as well and hence it redirects to https. I rewrote the redirect rule and it was ok.

Upvotes: 0

osynavets
osynavets

Reputation: 1520

In my situation it was caused by this piece of code:

services.Configure<MvcOptions>(options =>
{
    options.Filters.Add(new RequireHttpsAttribute());
});

Anyway double check you startup.cs file. Maybe configurations there are part of a problem

Upvotes: 3

Sergey
Sergey

Reputation: 41

It is not about Visual Studio, it is about Chrome. This solution worked for me: Google Chrome redirecting localhost to https

Upvotes: 3

Rohith
Rohith

Reputation: 5677

the redirect will only happen with explict configuration and IIS or asp.net will not automatically redirect .

  • check following config files and loo for any redirect settings
    • ApplicationHost.Config,All web.config files (C:\Windows\System32\inetsrv\config) search for httpRedirect

e.g. <httpRedirect enabled="true" destination="https://localhost" />

  • check for urlrewrite configurations. a typical rule will be like this .so you can search for Redirect

                <action type="Redirect" url="http://www.maindomain.com/{R:1}" />
            </rule>
    
    • If you do not find these settings anywhere in your configuration,your application code is doing this.Check your code

Upvotes: 2

Related Questions