IIS Express 上的 ASP.NET Core 3.1 应用程序:“无法访问此站点" [英] ASP.NET Core 3.1 app on IIS Express: "This site can't be reached"
问题描述
我正在开发一个从 v2.2 升级到 v3.1 的 ASP.NET Core 应用程序.
当我在没有启用 SSL 的情况下使用 IIS Express 启动应用程序时,我在 Google Chrome 中收到此错误:
<块引用>无法访问此站点.本地主机拒绝连接.
当我启用 SSL 时,我收到此错误:
<块引用>无法找到此本地主机页面.找不到该网址的网页:.
当我创建一个新的空白 ASP.NET Core 3.1 Web 项目并在 IIS Express 上使用相同的设置运行它时,它运行良好.
根据其他地方的建议,我尝试了以下方法:
- 清理和重建
- 删除 web 项目中的 .vs 文件夹
- 更改端口号(当前为 localhost:54236).
- 启用/禁用 SSL
- 重新启动我的机器
- 在单独的工作目录中从 Git 加载我的解决方案的新副本并尝试运行它.
我不知所措.
这是我的 launchSettings.json 文件:
<代码>{iis设置":{windowsAuthentication":假,匿名身份验证":真,iis":{"applicationUrl": "http://myapplication.debug",ssl端口":0},iisExpress":{"applicationUrl": "http://localhost:54236",sslPort":44367}},个人资料":{IIS Express":{"commandName": "IISExpress",启动浏览器":真,环境变量": {"ASPNETCORE_ENVIRONMENT": "开发"}},网络":{"commandName": "项目",启动浏览器":真,环境变量": {"ASPNETCORE_ENVIRONMENT": "开发"},"applicationUrl": "https://localhost:5001;http://localhost:5000"}}}
与新项目的 launchSettings.json 文件进行比较时,我看不出任何显着差异.还有什么会导致这个失败吗?
我应该注意到我确实更改了端口号 - 它最初在端口号 50192,但是当我尝试将网站运行到该地址时 (
从 aspnetcore 2.2 升级到 3.1 时,我的 Program.cs 中似乎缺少某些内容.
直到现在我有这个:
return WebHost.CreateDefaultBuilder(args).ConfigureServices(services => services.AddAutofac()).UseStartup();
在查看一个新的 v3.1 项目时,它有类似的东西:
public static IHostBuilder CreateHostBuilder(string[] args) =>Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>{webBuilder.UseStartup();});
I'm working on an ASP.NET Core application that I have upgraded from v2.2 to v3.1.
When I start the application using IIS Express without SSL enabled, I get this error in Google Chrome:
This site can't be reached. localhost refused to connect.
When I enable SSL, I get this error instead:
This localhost page can't be found. No web page was found for the web address: https://localhost:44367.
I have have an IIS website configured to the directory where my application sits. In the project settings, I can set the 'Launch' setting to 'IIS', but when I do this I also get the same error.
Screenshot of my web project settings: .
When I create a new blank ASP.NET Core 3.1 web project and run it with the same settings on IIS Express, it runs fine.
Based on suggestions elsewhere, I have tried the following:
- Cleaning and rebuilding
- Deleting the .vs folder in the web project
- Changing the port number (currently it is localhost:54236).
- Enabling/disabling SSL
- Restarting my machine
- Loading up a fresh copy of my solution from Git on a separate working directory and trying to run it.
I'm at a loss.
Here is my launchSettings.json file:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "http://myapplication.debug",
"sslPort": 0
},
"iisExpress": {
"applicationUrl": "http://localhost:54236",
"sslPort": 44367
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Web": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
When comparing with the launchSettings.json file of a fresh project I can't see any notable difference. Is there anything else that would cause this failure?
I should note that I did change the port number - it was initially at port number 50192, but when I attempt to run the website to that address (
It appears I was missing something in my Program.cs when upgrading from aspnetcore 2.2 to 3.1.
Until now I had this:
return WebHost.CreateDefaultBuilder(args)
.ConfigureServices(services => services.AddAutofac())
.UseStartup<Startup>();
On looking at a fresh v3.1 project, it had something like this instead:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
这篇关于IIS Express 上的 ASP.NET Core 3.1 应用程序:“无法访问此站点"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!