简体   繁体   English

.NET 网站托管在 Azure Windows VM - IIS Web 服务器(VM)重启后服务器无法工作

[英].NET Website hosted on Azure Windows VM - IIS Web Server fails to work after Server (VM) restart

Hosted a .NET 6 basic Web App in IIS Web Server inside the Azure Virtual Machine (Windows 2016 Data Center) .NET 6 basic Web App 托管在IIS Web 服务器里面 Azure 虚拟机(Windows 2016 Data Center)

Commands :命令

dotnet new webapp
dotnet run
dotnet publish -c Release

3rd command is used for placing release folder files in the Site Physical Path created in IIS Web Server :第三条命令用于将发布文件夹文件放置在 IIS Web 服务器中创建的站点物理路径中

在此处输入图像描述

It shown the result as welcome page.它将结果显示为欢迎页面。 After VM Stop and Start action, it is showing the localhost as " The Site can't be reached "在 VM Stop 和 Start 操作之后,它显示本地主机为“ The Site can't be reached

If I create new site on Connections of the IIS Manager, then it is working.如果我在 IIS 管理器的连接上创建新站点,那么它就可以工作。 Every time after restarting the VM, Creating New Site is not the solution.每次重新启动 VM 后,创建新站点都不是解决方案。 Why previously created Site is showing me " The Site can't be reached " error.为什么以前创建的网站显示“ The Site can't be reached ”错误。

What I have tried :我试过的

  1. Tested by creating new Site in Connections of the IIS Manager, it worked for the new site but after restarting the VM, it also stopped working and showing above mentioned error.通过在 IIS Manager 的连接中创建新站点进行测试,它适用于新站点,但在重新启动 VM 后,它也停止工作并显示上述错误。
  2. Checked VM Status, it is Healthy检查 VM 状态,它是健康的
  3. All required tools are installed in the VM (VS Code, .NET 6 SDK, Runtime, and Hosting Bundle)所有必需的工具都安装在 VM 中(VS Code、.NET 6 SDK、Runtime 和 Hosting Bundle)

Note: It is working successfully after I clear the cache in the browser after server restart (stop and start) but why I have to clear the browser cache every time after VM stop and start ?注意:我在服务器重启(停止和启动)后清除浏览器中的缓存后它工作成功,但为什么每次 VM 停止和启动后我都必须清除浏览器缓存

Update:更新:

Forgot to mention this:忘了提这个:

I have given HTTPS binding to the IIS Manager Website Hosted so if do localhost with port 80, it will shows IIS Web Served Home Page and localhost with Https (443), it will show the hosted website content.我已将 HTTPS 绑定到托管的 IIS 管理器网站,因此如果使用端口 80 执行本地主机,它将显示 IIS Web 服务主页和本地主机与 Https (443),它将显示托管网站内容。

After Server Stop and Start, localhost with port 80 gives the IIS Web Served Home Page and localhost with Https is not giving the website content, here it is giving error "The site is not reached".服务器停止和启动后,端口为 80 的本地主机提供 IIS Web 服务主页和本地主机 Https 未提供网站内容,此处显示错误“未到达该站点”。

I tried to reproduce the same in my environment and I got the results like below:我尝试在我的环境中重现相同的内容,得到如下结果:

I have created sample website and when I tried Stop and Start action, localhost reached successfully:我创建了示例网站,当我尝试停止和启动操作时,localhost 成功到达:

在此处输入图像描述

在此处输入图像描述

As suggested by samwu you can check event viewer like below:正如samwu所建议的,您可以像下面这样检查事件查看器:

In start -> select event viewer -> click Windows Logs node在开始 -> select 事件查看器 -> 单击 Windows 日志节点

在此处输入图像描述

Select application Event Log and Search for errors associated with the failing app like below Select 应用程序事件日志并搜索与失败应用程序相关的错误,如下所示

在此处输入图像描述

You can make use of Debug Diagnostics tool .您可以使用调试诊断工具

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM