简体   繁体   English

如何允许 IIS express 访问任何文件扩展名

[英]How to allow IIS express to access any file extensio

I have multiple images but i have changed the extension for my own purpose.我有多个图像,但我出于自己的目的更改了扩展名。 So I have multiple extension.所以我有多个扩展名。 When I try to display my image I got an error that my extension is not mapped to a mime type.当我尝试显示我的图像时,我收到一个错误,我的扩展没有映射到 MIME 类型。 So how can I display my image without changing the extension because I have a lot.那么如何在不更改扩展名的情况下显示我的图像,因为我有很多。 With Apache wamp server I tested all images and it can be displayed.使用 Apache wamp 服务器我测试了所有图像并且可以显示它。

Then with IIS express included within visual studio 2017, is there a way to do the mapping.然后在visual studio 2017中包含IIS express,有没有办法进行映射。 I also did the mapping individually but this cannot be good solution for me because I have many images file.我也单独进行了映射,但这对我来说不是一个好的解决方案,因为我有很多图像文件。

You can change the config file that IIS express use it:您可以更改 IIS express 使用它的配置文件:

  1. Right click on IIS Express icon on traybar then click on " Show All Application "右键单击托盘栏上的 IIS Express 图标,然后单击“显示所有应用程序

打开配置文件

  1. Select your application name and click on config address in bottom of application list.选择您的应用程序名称,然后单击应用程序列表底部的配置地址。

打开配置文件

  1. Opened file contains xml elements.打开的文件包含 xml 元素。 you must find " staticConten " element then add your intended mapping.您必须找到“ staticConten ”元素,然后添加您想要的映射。

在此处输入图片说明

If you run iisexpress.exe from the command line, the config file it uses will be in AppServer/applicationhost.config .如果您从命令行运行 iisexpress.exe,它使用的配置文件将在AppServer/applicationhost.config Add the mime types you need to that file in the section <staticContent> and restart iisexpress.将您需要的 MIME 类型添加到 <staticContent> 部分中的该文件并重新启动 iisexpress。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM