I have a website running under IIS on Windows 7. Everytime the webpage requests an XML file I receive a 400 Bad Request (diagnosed through firebug). If I request the XML file directly by typing it into my browser it works.
This not only happens for .xml
file extensions but .xsl
too; both of which contain XML data.
I found the issue.
When requesting the XML files I was adding the If-Modified-Since
header which is in the HTTP spec but IIS on Windows 7 seems to return 400 Bad Request
when this is added. Simply removing this header from the request fixes the issue.
Is your xml file static or dynamically generated?
If static then check the following:
Your (successful) browser request would be using a GET request. Is your webpage request using POST? If so, POST may not be an accepted verb for a static xml file.
Check the IIS configuration settings for .xml suffix files.
来源:https://stackoverflow.com/questions/4725729/iis-on-windows-7-400-bad-request-when-requesting-xml-files