8

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?

nealkernohan
  • 788
  • 1
  • 6
  • 15
  • In your solution folder you will find .vs folder. Try deleting it and rerunning application. You may have some redirection config in applicationhost.config file present in config folder inside .VS folder. – Pankaj Kapare Jul 26 '17 at 20:31
  • Try this solution - https://stackoverflow.com/questions/63825407/microsoft-edge-redirects-http-localhost-to-https-localhost It solves the same issue. – Андрей Савельев Oct 22 '20 at 15:32
  • Try this solution - https://stackoverflow.com/questions/63825407/microsoft-edge-redirects-http-localhost-to-https-localhost it solves the same issue for me. – Андрей Савельев Oct 22 '20 at 15:34

4 Answers4

3

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

Sergey
  • 41
  • 1
2

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
Rohith
  • 5,527
  • 3
  • 27
  • 31
1

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

osynavets
  • 1,199
  • 1
  • 12
  • 22
0

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.

OneGhana
  • 119
  • 5