IIS:如何在没有扩展名的情况下提供文件? [英] IIS: How to serve a file without extension?

查看:143
本文介绍了IIS:如何在没有扩展名的情况下提供文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 8.1 上使用 IIS 8 。我有一个 XML 文件,我需要通过(servername)/(路径)

I am using IIS 8 on Windows 8.1. I have an XML file an I need to have it accessed through (servername)/(path)

(路径)由其他人预定义,不包含扩展名。我尝试了删除文件名的.xml文件的简单解决方案,但 IIS返回HTTP错误404.3 - 未找到

(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

物理路径中返回错误的是正确的文件路径,当我复制粘贴到Run时会打开正确的文件。

In the "Physical Path" returned with the error is the correct file path, which when I copy-paste to Run opens the correct file.

如果可能,请告诉我。

推荐答案

假设(路径)是您机器上的物理目录,请创建该目录中的新web.config文件包含以下内容:

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>

您告诉IIS仅对于此目录,任何没有其他定义扩展名的文件(在MIME类型中) )应该被认为是一个xml文件。同一路径中的其他文件类型仍应有效。

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.

这篇关于IIS:如何在没有扩展名的情况下提供文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆