首页 > 解决方案 > 是否可以在 Windows 8.1 上以 Kestrel 模式运行 Blazor 客户端?

问题描述

我正在尝试在我的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 App上没有任何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-corewindows-8.1blazor-client-sideblazor-webassemblykestrel

解决方案


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


推荐阅读