ASP.NET MVC路由与保留文件名在Windows [英] ASP.NET MVC Routing vs. Reserved Filenames in Windows
问题描述
在我们的ASP.NET MVC应用程序,我们已经注意到,我们不能有禁DOS文件名— COM1
到 COM9
, LPT1
到 LPT9
, CON
, AUX
, PRN
和 NUL
—在任何地方我们路线。他们不可避免地导致IIS告诉我们不能找到该文件,甚至当我们设置路由不首先检查文件是否存在。我们如何解决此问题?
In our ASP.NET MVC application, we've noticed that we cannot have The Forbidden DOS File Names—COM1
through COM9
, LPT1
through LPT9
, CON
, AUX
, PRN
, and NUL
—anywhere in our routes. They inevitably result in IIS telling us the file cannot be found, even when we set routing not to check for the existence of files first. How can we work around this?
推荐答案
本已在ASP.NET 4 <解决的href=\"http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx\">http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx
This has been addressed in ASP.NET 4. http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx
您可以应用在web.config中是放宽这一限制的设置。
You can apply a setting in web.config that relaxes this restriction.
<configuration>
<system.web>
<httpRuntime relaxedUrlToFileSystemMapping="true"/>
<!-- ... your other settings ... -->
</system.web>
</configuration>
希望有所帮助。
这篇关于ASP.NET MVC路由与保留文件名在Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!