Dave
Dave

Reputation: 4028

Visual Studio not launching browser when debugging ASP.Net app

I have Blazor WASM app that is ASP.Net hosted. When I try to debug the server app, Visual Studio does not launch the selected web browser.

When I run the app (F5), the project builds, and VS goes into debug mode, but the browser window never launches.

I have confirmed that Microsoft Edge is the selected browser, and script debugging is disabled.

Other projects on this machine work properly.

My launch settings are unmodified out of the box.

{
    "iisSettings": {
      "windowsAuthentication": false,
      "anonymousAuthentication": true,
      "iisExpress": {
        "applicationUrl": "http://localhost:63525",
        "sslPort": 44395
      }
    },
    "profiles": {
      "REDACTED": {
        "commandName": "Project",
        "dotnetRunMessages": true,
        "launchBrowser": true,
        "launchUrl": "",
        "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
        "applicationUrl": "https://localhost:7290;http://localhost:5290",
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        }
      },
      "IIS Express": {
        "commandName": "IISExpress",
        "launchBrowser": true,
        "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        }
      }
    }
  }

This project launched properly in the past, but suddenly stopped. I don't know what I could have changed.

I have updated to the latest version of Visual Studio (17.3.0), restarted my machine, and deleted the .vs folder. Nothing has worked so far.

Edit: I just noticed that a PowerShell window is opening when I run my app. I get the following error.

AppName.exe (process 2372) exited with code -1.

I am still not sure what is causing this issue. The code in Program.cs seems to execute without any issue, but when it gets to app.Run(), the program exits.

Upvotes: 4

Views: 2816

Answers (1)

Dave
Dave

Reputation: 4028

This was caused by a call to Task.Delay() in StartAsync() of a IHostedService.

My intention was to run a background task on a timer, but I wanted to add a delay before kicking off the timer. Because this delay was in StartAsync, it was delaying the entire startup of the app.

Upvotes: 3

Related Questions