在 Blazor 应用程序中设置默认浏览器

问题描述 投票:0回答:1
  • 我系统上的默认浏览器是 Chrome,它有我喜欢的主题和自定义设置。在 Visual Studio 2022 中,选择同一浏览器作为我的默认浏览器。当运行像 Application.MVC 这样的项目时,这个浏览器启动时没有任何问题。但是,不幸的是,当我运行 Application.Blazor 项目时,该程序在单独的 Chrome 实例中运行。此实例缺少我喜欢的主题和自定义设置,并且它没有登录到我的任何帐户(例如 Gmail)。

如何确保我的 Application.Blazor 项目在我的默认 Chrome 浏览器中运行并具有我的所有首选设置?我需要在 launchSettings.json 文件中进行任何特定设置吗?

我的午餐设置.Json 文件

{
  "profiles": {
    "http": {
        "commandName": "Project",
        "launchBrowser": true,
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "dotnetRunMessages": true,
        "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
        "applicationUrl": "http://localhost:5022"
       
    },

    "https": {
        "commandName": "Project",
        "launchBrowser": true,
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "dotnetRunMessages": true,
        "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
        "applicationUrl": "https://localhost:7272;http://localhost:5022"
    },
    "IIS Express": {
        "commandName": "IISExpress",
        "launchBrowser": true,
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
    }
  },
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:1318/",
      "sslPort": 44381
    }
  }
}

我测试了 Visual Studio 2022 中的 BrowserWith 设置以及 launchSettings.json 文件中的

 preferredBrowser
设置,还尝试了一系列其他设置,但没有效果。

.net blazor
1个回答
0
投票

您可以使用参数将新的 chrome 浏览器实例添加到 Visual Studio 并添加

--profile-directory=Default

--profile-directory="Nameofyourprofile"
© www.soinside.com 2019 - 2024. All rights reserved.