【问题标题】:Is it possible to run Blazor Client in Kestrel mode at Windows 8.1?是否可以在 Windows 8.1 上以 Kestrel 模式运行 Blazor 客户端?
【发布时间】:2021-02-06 18:40:38
【问题描述】:

我试图在我的 Windows 8.1 机器上运行 Blazor Web Assembly 应用程序,但没有成功。由于 Windows 8.1 操作系统不推荐 Kestrel 模式,我在其他示例项目(MVC、Razor Page、Blazor Server 和 API)中使用了这种硬编码在 appsettings.js 符号:

  "Kestrel": {
    "EndpointDefaults": {
      "Protocols": "Http1"
    }
  }

而且效果很好。 但是在 Blazor Web Assembly 应用程序 上没有任何 appsettings.js 文件。 appsettings.js 有一个具有这种默认结构的 launcheSettings.json 文件:

  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:55974",
      "sslPort": 44318
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "BlazorClientDemoApp": {
      "commandName": "Project",
      "launchBrowser": true,
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }

当我尝试对上述 Kestrel 的代码进行硬编码时,应用程序不会出现在浏览器上。

在 Windows 8.1 操作系统上可以做到吗?

规格:

Windows 8.1 64bit
VisualStudio 2019: 16.7.6 version,
SDK 3.1.403 Core,
Microsoft .NET Framework Wersja 4.8.03761,
ASP.NET and Web Tools 2019   16.7.532.,
ASP.NET Core Razor Language Services   16.1.0.,
ASP.NET Web Frameworks and Tools 2019   16.7.532.28833


【问题讨论】:

    标签: asp.net-core windows-8.1 blazor-client-side blazor-webassembly kestrel


    【解决方案1】:

    我不确定我是否理解,但您可以使用“wwwroot/appsettings.json”作为常规“appsettings.json”的对应项。当您从“Program.cs”中调用 builder.Configuration.GetValue... 之类的内容时,将从该 json 文件中获取值。

    【讨论】:

      猜你喜欢
      • 2018-03-04
      • 2019-11-13
      • 2016-05-27
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-04
      相关资源
      最近更新 更多