Why does my ASP.NET webpage throw custom 404 error with certain file extensions

So, I have a folder on my server such like this:

enter image description here

You can access this resources by the URL:

enter image description here

enter image description here

But the kmz, instead of opening the file (maybe like the text in the xml, I'm not expecting to visualize it) it returns a strange 404:

enter image description here

Is there any way of allowing all files to be accessed without an error? Thank you very much.

Upvotes: 0

Views: 321

Answers (1)

Brando Zhang
Brando Zhang

Reputation: 28387

As far as I know, if you wants to access the kmz file in the browser, you will face 404.3 error.

Error details:

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

To solve this issue, you should add the MIME map for kmz file.

I suggest you could add below config file into the web.confil, then it will work well.

  <system.webServer>
    <staticContent>
      <remove fileExtension=".kml" />
      <mimeMap fileExtension=".kml" mimeType="application/vnd.google-earth.kml+xml" />
      <remove fileExtension=".kmz" />
      <mimeMap fileExtension=".kmz" mimeType="application/vnd.google-earth.kmz" />
    </staticContent>
  </system.webServer>

Upvotes: 2

Related Questions