IIS 错误 404 即使文件存在,aspx 正常打开



我无法访问html页面或任何图像文件,只有我能够访问成功的.apsx asmx和ashx文件。我收到404 - 找不到文件或目录

例如:

mysite.com/index.html  ( getting 404 error)
mysite.com/image.jpg( getting 404 error)
mysite.com/page.aspx (working fine)
mysite.com/service.asmx/method  ( working fine)

我尝试做的事情:

  1. 检查 IUSR 和IIS_IUSRS的文件夹权限在那里。
  2. 哑剧类型
  3. 映射处理程序

我将发布我的 web.config 设置。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000" />
</webServices>
</scripting>
</system.web.extensions>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" />
<authentication mode="None" />
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="ScriptHandlerFactory" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="PHP5" path="*.php" verb="*" modules="CgiModule" scriptProcessor="C:******php-cgi.exe" resourceType="Unspecified" requireAccess="Script" />
<add name="uploadfile" path="uploadfile.ashx" verb="*" type="Namespace.uploadfile" />
</handlers>
</system.webServer>
<connectionStrings>
<add name="SalikConnection" connectionString="Data Source=**************;Initial Catalog=*****;uid=*****;password=****************;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

有什么建议吗?

编辑和解决

将静态内容添加到 web.config

<system.webServer>
<handlers>
<clear />
<add 
name="StaticFile" 
path="*" verb="*" 
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" 
resourceType="Either" 
requireAccess="Read" />
</handlers>
<staticContent>
<mimeMap fileExtension=".*" mimeType="application/octet-stream" />
</staticContent>

请确保您在Windows功能对话框中的IIS下选中了"静态内容"复选框。检查屏幕截图

静态内容

最新更新