开发者

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

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
  2. If your server is using a shared IP address across multiple sites have you configured a HTTP host header?
  3. Is there a mime type set for the .txt extension?
  4. Have you made any changes to the Handler Mappings for the site? e.g. mapped the .htm extension to say the ASP ISAPI filter and accidentally removed the StaticFile handler?
  5. Can you serve other static content such as .jpg, .gif, .pdf etc?


Kev has covered most of the possible problems, but for reference there is another possibility.

Confirm that in Request Filtering you either

  • have .txt as an Allowed extension, or
  • have Allow unlisted file name extensions ticked in Edit Request Filtering Settings

The same effect can be achieved with the following web.config section:

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


Add the MIME-Typ by going to ...

  1. features / Mime-type
  2. right click,
  3. add,
  4. put in the file extension ".txt"
  5. and the mime-type "text/plain"
  6. ok

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. In my case it turned out that static files are served from a subdirectory called 'wwwroot' by default. Creating that subdirectory and moving the file in their solved it for me:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜