-1

For some reason, Visual Studio 2017 (version 15.9.12), refuses to load ASP.Net Dotnet Core 2.2 pages in non-ssl. It automatically appends an s to http as in https://localhost:15777 even though Enable SSL is unchecked and the Launch brower path is set to http://localhost:15777 (or for Kestrel, it's set to http://localhost:55333).

The launchSettings.json file looks like so (as you can see, it's set correctly, but completely ignored).

    {
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:15777",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "http://localhost:15777",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Nop.Web": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:55333"
    }
  }
}

This, didn't do this a week ago, and I've scoured posts here and there looking for an answer. Obviously, there is a bug somewhere, so I'm looking for a hack to make Visual Studio, IIS Express or Kestrel work like it's supposed to. Any ideas?

MC9000
  • 2,076
  • 7
  • 45
  • 80
  • Possible duplicate of [ASP.NET Core 2.1 + Kestrel (How to disable HTTPS)](https://stackoverflow.com/questions/50935730/asp-net-core-2-1-kestrel-how-to-disable-https) – Lex Li Jun 10 '19 at 04:32
  • I saw that, but for Core 2.2, everything changed. Still trying to make sense of why Core 2.2 is so friggin' buggy - never had such a ridiculous problem before. – MC9000 Jun 11 '19 at 05:23
  • "everything changed" is vague. That threads have several answers that are valid even for 3.0 (like `.UseUrls("http://localhost:5000")`). – Lex Li Jun 11 '19 at 05:28

1 Answers1

0

it doesn't relate to visual studio. you have to remove the app.UseHttpsRedirecttion(); in Startup.cs file

also, you may run your Release and because of app.UseHsts() it will redirect to https until its time expires. try to clear your browser security cache. you can clear hsts security cache by going to chrome://net-internals/#hsts and delete the address you want.

Peyman
  • 143
  • 2
  • 6
  • Not using this in the Startup.cs at all. Is this a default behavior in the dotnet core 2.2 pipeline? – MC9000 Jun 11 '19 at 05:17
  • I removed VS2017 completely, then installed VS2019 and get the same behavior. https - no... matter... what. It's not defined anywhere - I hard coded the urls, and it insists on doing this. So, it's not VS, but a bug/feature in Kestrel? Using Core 2.2.3 SDK – MC9000 Jun 11 '19 at 05:26
  • 1
    `.UseHttpsRedirection` is now part of `.CreateDefaultBuilder` in 2.2, so this answer itself is invalid. – Lex Li Jun 11 '19 at 05:30
  • 1
    I don't believe it is being part of the asp.net core.and i tried with ver 3.0-preview5 and had no problem. – Peyman Jun 11 '19 at 15:22
  • 1
    try with clearing HSTS security cache I just added to the answer.I hope that solve your problem.also you can try using another browser if you dont want to clear hsts cache – Peyman Jun 11 '19 at 15:30
  • Looks like the problem was with the app I was running - Nopcommerce 4.2. I created an app from scratch w/ and w/o https and it worked just fine. This rerouting is occurring somewhere in their code, so I can rule out Kestrel as well. This question should probably be deleted and a new one opened for Nop (or bug report). – MC9000 Jun 11 '19 at 17:46
  • nopCommerce uses settings stored in the database to redirect to https.you can find it in the place you can add new market(shop).this setting's name is `securitysettings.forcesslforallpages` change it's value to false and it'll be Ok – Peyman Jun 12 '19 at 09:40