简体   繁体   English

IIS 7.0出现404错误

[英]404 error with IIS 7.0

I have a text file that I am trying to browse to using the browser http://files.mydomain.com/test.txt and I get a: 我有一个文本文件,我试图浏览到使用浏览器http://files.mydomain.com/test.txt ,我得到一个:

HTTP Error 404.0 - Not found 

I double checked and the text file does exist. 我仔细检查,文本文件确实存在。 When I add a test.htm file, I have no issues. 当我添加test.htm文件时,我没有任何问题。

Can someone help? 有人可以帮忙吗? Something tells me it's security issue. 有些东西告诉我这是安全问题。

Have you checked the following: 你检查了以下内容:

  1. Your DNS 'A' record for 'files' is pointing to the correct IP address 您对''文件'的DNS'A'记录指向正确的IP地址
  2. If your server is using a shared IP address across multiple sites have you configured a HTTP host header? 如果您的服务器在多个站点上使用共享IP地址,您是否配置了HTTP主机头?
  3. Is there a mime type set for the .txt extension? 是否为.txt扩展名设置了mime类型?
  4. Have you made any changes to the Handler Mappings for the site? 您是否对网站的处理程序映射进行了任何更改? eg mapped the .htm extension to say the ASP ISAPI filter and accidentally removed the StaticFile handler? 例如,映射.htm扩展名以说明ASP ISAPI过滤器并意外删除了StaticFile处理程序?
  5. Can you serve other static content such as .jpg , .gif , .pdf etc? 你可以提供其他静态内容,如.jpg.gif.pdf等吗?

Kev has covered most of the possible problems, but for reference there is another possibility. Kev已经涵盖了大部分可能存在的问题,但作为参考,还有另一种可能性。

Confirm that in Request Filtering you either Request Filtering确认您

  • have .txt as an Allowed extension, or .txt作为允许的扩展名,或
  • have Allow unlisted file name extensions ticked in Edit Request Filtering Settings 在“ 编辑请求过滤设置”中选中“ Allow unlisted file name extensions

The same effect can be achieved with the following web.config section: 使用以下web.config部分可以实现相同的效果:

<system.webServer>
    <security>
        <requestFiltering>
            <fileExtensions>
                <add fileExtension=".txt" allowed="true" />
            </fileExtensions>
        </requestFiltering>
    </security>
</system.webServer>

Also make sure also that the website is started. 还要确保网站已启动。 I was getting 404 and then realized that the Default Website was stopped because another website (Sharepoint) was using port 80. Sometimes the obvious is what gets you. 我得到404,然后意识到默认网站已经停止,因为另一个网站(Sharepoint)正在使用端口80.有时显而易见的是什么让你。

Add the MIME-Typ by going to ... 通过转到...添加MIME类型

  1. features / Mime-type 功能/哑剧型
  2. right click, 右键点击,
  3. add, 加,
  4. put in the file extension ".txt" 放入文件扩展名“.txt”
  5. and the mime-type "text/plain" 和mime-type“text / plain”
  6. ok

et voila et voila

I know this is an old post, but this might still help somebody out. 我知道这是一个老帖子,但这可能仍然有助于某人。 I ran into this problem with my Asp.Net Core application. 我用我的Asp.Net Core应用程序遇到了这个问题。 In my case it turned out that static files are served from a subdirectory called 'wwwroot' by default. 在我看来,默认情况下,静态文件是从一个名为'wwwroot'的子目录中提供的。 Creating that subdirectory and moving the file in their solved it for me: 创建该子目录并移动文件,为我解决了它:

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/index?view=aspnetcore-2.2&tabs=windows#web-root https://docs.microsoft.com/en-us/aspnet/core/fundamentals/index?view=aspnetcore-2.2&tabs=windows#web-root

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

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