代码之家  ›  专栏  ›  技术社区  ›  QN Developer

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

  •  0
  • QN Developer  · 技术社区  · 8 年前

    我无法访问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\U IUSR的文件夹权限。
    2. MIME类型
    3. 映射处理程序

    我会发布我的网站。配置设置。

    <?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>
    

    有什么建议吗?

    已编辑(&A);已解决

    向web添加静态内容。配置

     <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>
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Mohsin Mehmood    8 年前

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

    Static Content