visual-studio - 调试 ASP.Net 应用程序时 Visual Studio 未启动浏览器

标签 visual-studio asp.net-core visual-studio-2022

我有 ASP.Net 托管的 Blazor WASM 应用程序。当我尝试调试服务器应用程序时,Visual Studio 不会启动选定的 Web 浏览器。

当我运行应用程序 (F5) 时,项目构建,VS 进入 Debug模式,但浏览器窗口从未启动。

我已确认 Microsoft Edge 是所选浏览器,并且脚本调试已禁用。

native 其他项目正常运行。

我的启动设置开箱即用,未经修改。

{
    "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"
        }
      }
    }
  }

这个项目过去正常启动,但突然停止了。我不知道我本可以改变什么。

我已经更新到最新版本的 Visual Studio (17.3.0),重新启动我的机器,并删除了 .vs 文件夹。到目前为止没有任何效果。

编辑:我刚刚注意到在我运行我的应用程序时会打开一个 PowerShell 窗口。我收到以下错误。

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

我仍然不确定是什么导致了这个问题。 Program.cs 中的代码似乎没有任何问题地执行,但是当它到达 app.Run() 时,程序退出。

最佳答案

这是由于在 IHostedServiceStartAsync() 中调用 Task.Delay() 引起的。

我的意图是在计时器上运行后台任务,但我想在启动计时器之前添加延迟。因为此延迟发生在 StartAsync 中,所以它延迟了应用程序的整个启动。

关于visual-studio - 调试 ASP.Net 应用程序时 Visual Studio 未启动浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73340662/

相关文章:

c# - UseJwtBearerAuthentication 失败,IDX10504 : Unable to validate signature, token 没有签名

unit-testing - Nunit 并行运行测试不起作用

c# - ASP.NET Core 2.0 防止重复条目

c# - VS2022 c# 在文件保存上添加私有(private)修饰符

c# - 如何强制 visual studio 使用小写类型生成属性(例如,字符串而不是字符串)

sql-server - 忽略 SSDT 部署后脚本中的错误

c# - 如何使用c#删除Word文档中的 'Read only recommended'选项?

c# - Xamarin Android 支持库 v4(不完整)?

c# - 在 C# 类中转到实现会导致反编译的类,而不是 Visual Studio 2022 中的原始类文件

C++嵌套类模板错误C2440 '=' : cannot convert from 'type' to 'same type'