Skow
Skow

Reputation: 23

JS: XMLHttpRequest only works on specific file extensions?

I'm working on a WebGL project. I'm using XMLHttpRequest to load shaders (text files), JSON models (text files). When I use XMLHttpRequest for a file with an unusual extension (such as .vs or .json), I will get a 404 status returned. If I rename that file to end in .txt or .html it will load fine (status 200). Any insight into what is limiting which files successfully are retrieved?

Sorry if this is a simple question, I'm new to web development. I've been unable to google fu an answer. I'm using IIS to serve the site locally.

Upvotes: 2

Views: 386

Answers (1)

ziesemer
ziesemer

Reputation: 28687

I'm guessing this has nothing to do with XMLHttpRequest. What happens when you try accessing those resources directly, through the address bar in your web browser, or something like cURL?

The default security configurations on IIS are most likely preventing serving of "unrecognized" files. You probably need to register MIME types for them, or disable the security configurations.

Some details around this are available at http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44aa974e-ad27-4800-adfb-13c4ae39a602.mspx?mfr=true . Note specifically:

You can also configure IIS to serve undefined file types by adding a wildcard character (*) MIME type. Do not use wildcard MIME-types on production servers. Doing so can result in IIS serving unrecognized files and displaying sensitive information to users. Wildcard MIME-types are intended for testing purposes or in scenarios where Internet Server API (ISAPI) filters have been developed specifically to handle these wild card scenarios, for example, a custom authentication ISAPI.

If you need additional assistance with this, http://serverfault.com may be a better place to ask for details on configuring IIS.

Upvotes: 2

Related Questions