这个问题可能是由于缺少配置或IIS Express配置错误导致的。要解决此问题,请按照以下步骤进行操作:
launchSettings.json
文件,并检查以下设置:"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express (BlazorWebAssembly)": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5000",
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
}
}
确保ASPNETCORE_ENVIRONMENT
设置为开发环境,IIS Express (BlazorWebAssembly)
应用程序URL设置为http://localhost:5000
,并且检查URI设置正确。
如果步骤1中的设置正确,则可以尝试将IIS Express端口更改为其他值。在Visual Studio中,单击项目文件夹并打开属性窗口。在调试选项卡中,更改应用程序URL的端口号。您还可以在launchSettings.json
文件中手动更改端口号。
如果热重载仍然无法正常工作,请查看项目的Startup.cs
文件,确保services.AddServerSideBlazor()
中已启用CSS支持:
public void ConfigureServices(IServiceCollection services)
{
services.AddServerSideBlazor()
.AddHubOptions(o =>
{
o.MaximumReceiveMessageSize = 1024 * 1024 * 100;
})
.AddCircuitOptions(o =>
{
o.DetailedErrors = true;
})
.AddHubOptions(o =>
{
o.Enable