如何调试 Windows Server 2016 IIS“错误 404 - 未找到文件或目录”

如何调试 Windows Server 2016 IIS“错误 404 - 未找到文件或目录”

我无法在新的 AWS EC2 VM Windows Server 2016 上运行我的 ASP .NET Web 应用程序。Web 应用程序已在 Azure VM Windows Server 2012 R2 上运行多年。

问题:
我得到:

“错误 404 - 未找到文件或目录”

..当我尝试从外部互联网或服务器本身浏览托管在新 AWS EC2 VM 上的 Windows Server 2016 IIS 上的 ASP.NET Web 应用程序时。如果我从 IIS > 站点 > 我的网站 > 管理网站 > 浏览进行浏览,也会出现同样的错误

当我删除并重新添加网站时,出现此错误(另请参见下面的屏幕截图):

IIS > 添加网站 > 测试连接 > 黄色警告标志无法验证对路径的访问(我的 Web 应用项目的路径)

尝试修复...
IIS > 连接 > my_web_site > 浏览不起作用:“找不到网页”
IIS > 连接 > my_web_site > 管理网站 > 浏览 cmd 获取服务器错误 404 文件或目录未找到
IIS > 连接 > my_web_site > 编辑绑定 > 浏览获取服务器错误 404 文件或目录未找到

我尝试删除 IIS > 站点 > 我的网站,然后重新添加。仍然出现错误 404。

背景...
ASP.NET 在之前的 Azure VM Windows Server 2012 R2 上运行良好。
当我在新的 AWS VM 上从 Visual Studio 调试 ASP.NET 应用程序时,它运行良好。
所有 IIS 绑定的设置与之前的 Azure VM 一样。

错误...
在此处输入图片描述

WEB 应用程序的 IIS 属性...………. 在此处输入图片描述

IIS 日志位于 C:\inetpub\logs\LogFiles\

有 3 个子文件夹:

W3SVC1\ 包含以下文件.....

    #Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2019-01-12 15:02:21
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2019-01-12 15:02:21 172.31.37.156 GET / - 80 - 52.15.212.41 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 3 50 78
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2019-01-12 15:54:19
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2019-01-12 15:54:19 172.31.37.156 GET / - 80 - 52.15.212.41 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 3 50 156
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2019-01-12 17:37:36
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2019-01-12 17:37:36 172.31.37.156 GET /wp-login.php - 80 - 185.234.217.208 Mozilla/4.0+(compatible;+MSIE+9.0;+Windows+NT+6.1;+125LA;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.04506.648;+.NET+CLR+3.5.21022) http://prayshep.com/wp-login.php 404 0 2 171
2019-01-12 17:37:36 172.31.37.156 GET /wp-login.php - 80 - 185.234.217.208 Mozilla/4.0+(compatible;+MSIE+9.0;+Windows+NT+6.1;+125LA;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.04506.648;+.NET+CLR+3.5.21022) http://prayshep.com/wp-login.php 404 0 2 125
2019-01-12 17:48:43 172.31.37.156 GET /Default.aspx - 80 - 73.70.70.121 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/64.0.3282.140+Safari/537.36+Edge/17.17134 - 404 3 50 93
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2019-01-12 23:31:12
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2019-01-12 23:31:12 172.31.37.156 GET / - 80 - 52.15.212.41 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 3 50 46
2019-01-12 23:31:13 172.31.37.156 GET / - 80 - 52.15.212.41 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 3 50 31
2019-01-12 23:34:18 172.31.37.156 GET / - 80 - 52.15.212.41 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 3 50 15
2019-01-12 23:38:39 172.31.37.156 GET / - 80 - 52.15.212.41 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 3 50 31

W3SVC2\ 包含以下文件.....

#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2019-01-12 22:11:19
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2019-01-12 22:11:19 172.31.37.156 GET / - 80 - 52.53.201.78 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10_12_6)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/61.0.3163.100+Safari/537.36 - 404 3 50 109
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2019-01-12 23:39:21
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2019-01-12 23:39:21 172.31.37.156 GET / - 80 - 52.15.212.41 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 3 50 78
2019-01-12 23:40:11 172.31.37.156 GET / - 80 - 52.15.212.41 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 3 50 15
2019-01-12 23:43:17 172.31.37.156 GET / - 80 - 73.70.70.121 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/64.0.3282.140+Safari/537.36+Edge/17.17134 - 404 3 50 78

W3SVC3\ 包含以下文件.....

    #Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2019-01-12 23:32:18
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2019-01-12 23:32:18 ::1 GET / - 80 - ::1 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 3 50 109

IIS > 连接 > 我的网站 > 默认文档 在此处输入图片描述

我的 ASP .NET Web 应用程序的目录

IIS > 添加网站 > 测试连接 在此处输入图片描述

答案1

您的域名似乎指向了正确的服务器,并且 IIS 正在响应您的初始请求。您收到的 404 错误是由 IIS 生成的。

您是否检查了 Web 应用的默认文档设置?它应该与您的应用默认文档相匹配,例如 default.aspx。确认您引用的是正确的页面,即默认文档设置中的登录页面。

另外,请确保您运行的是适合您的 Web 应用的正确版本的 .NET 框架。可以从 IIS 中的应用程序池页面更新 .NET Framework 版本。

尝试从绑定中删除主机名并从服务器本身浏览(通过 IIS 控制台)以查看应用程序是否打开。在这种情况下,您只会绑定到计算机上可用的 IP 地址,并使用空白主机名。从公共端浏览时,您需要在浏览器中输入 IP。

检查您的 web.config(在您的 Web 应用程序文件夹中)配置,有时这些配置会向 IIS 添加额外的配置并导致不必要的麻烦。如果 web.config 中没有任何有价值的内容,请尝试从 Web 应用程序文件夹中删除该文件并重试。

其他故障排除步骤包括删除整个应用程序,并在 Web 应用程序文件夹中放入一个基本的 index.html 页面。更新您的默认文档设置以引用此新页面。再次从 IIS 浏览。

答案2

查看您的 IIS,似乎 asp.net 安装尚未完成。转到 IIS 角色下的 Windows 功能安装 asp.net。安装后,您将在 IIS 中看到 ASP.net 配置。

这就是 IIS 无法读取您的文件的原因。

相关内容