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:
- Your DNS 'A' record for 'files' is pointing to the correct IP address
- If your server is using a shared IP address across multiple sites have you configured a HTTP host header?
- Is there a mime type set for the
.txt
extension? - 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? - 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 ...
- features / Mime-type
- right click,
- add,
- put in the file extension ".txt"
- and the mime-type "text/plain"
- 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
精彩评论