繁体   English   中英

IIS错误404甚至文件已存在,aspx正常打开

[英]IIS error 404 even file existsn, aspx opens normally

我无法访问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. MIME类型
  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下选中“静态内容”复选框。 检查截图

静态内容

暂无
暂无

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

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