Unable to run C# .NET Core API project on IIS/IIS Express in Windows 7

Have an Angular 6 UI project running successfully which is supposed to make HTTP calls to API project, but currently I am unable to run API project on my machine.
I have the following lines of code in “launchSettings.json” file:

"iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
        "applicationUrl": "https://localhost:56467/",
        "sslPort": 44352

I have the following lines of code in “Startup.cs” file, to redirect http traffic to https (https://neelbhatt.com/2018/02/04/enforce-ssl-and-use-hsts-in-net-core2-0-net-core-security-part-i/)

public void configure(){
    var options = new RewriteOptions();
    options.AddRedirectToHttps(StatusCodes.Status301MovedPermanently, 63423);

On running the API object on IIS, web browser opens up first on https://localhost:56467/ and then redirects to https://localhost:63423/ and says cannot load the page. However, on manually changing port to 44352 (https://localhost:44352/) launches the swagger page of the API project. Since we changed the port manually, the Angular UI project is unable to hit the breakpoint placed in the API project controller. I have tried commenting out AddRedirectToHttps code in Startup.cs/configure() method, but still getting the same error. FYI, the same code works on my colleagues Windows 7 machines.

Any help on how to resolve this issue and how to run API project on port https://localhost:44352/ ?

Leave a Reply

Notify of