I am using IIS 8
on Windows 8.1
. I have an XML
file an I need to have it accessed through (servername)/(path)
(path) is predefined by someone else and does not contain an extension. I tried the simple solution of removing the .xml file the file name, but IIS returns HTTP Error 404.3 - Not Found
In the "Physical Path" returned with the error is the correct file path, which when I copy-paste to Run opens the correct file.
Please let me know if this is possible.
Assuming (path) is a physical directory on your machine, create a new web.config file in that directory with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension="." mimeType="text/xml" />
</staticContent>
</system.webServer>
</configuration>
You are telling IIS that for this directory only, any file without an otherwise defined extension (in MIME types) should be considered an xml file. Other file types in the same path should still work.
If you have the Windows feature IIS Management Scripts and Tools
installed, you can use PowerShell to create such a web.config file:
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site/.well-known' -filter "system.webServer/staticContent" -name "." -value @{fileExtension='.';mimeType='text/xml'}
in this example Default Web Site
is the name of the web site and .well-known
is a directory under that site.