ASP.NET MVC 路由与 Windows 中的保留文件名 [英] ASP.NET MVC Routing vs. Reserved Filenames in Windows
问题描述
在我们的 ASP.NET MVC 应用程序中,我们注意到我们不能有 The Forbidden DOS File Names—COM1
到 COM9
、LPT1
> 通过 LPT9
、CON
、AUX
、PRN
和 NUL
—任何地方在我们的路线中.它们不可避免地导致 IIS 告诉我们找不到文件,即使我们设置路由不首先检查文件的存在.我们如何解决这个问题?
此问题已在 ASP.NET 4 中解决.http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx
您可以在 web.config 中应用放宽此限制的设置.
<预><代码><配置><system.web><httpRuntime RelaxUrlToFileSystemMapping="true"/><!-- ...您的其他设置...--></system.web></配置>希望有所帮助.
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?
This has been addressed in ASP.NET 4. http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx
You can apply a setting in web.config that relaxes this restriction.
<configuration>
<system.web>
<httpRuntime relaxedUrlToFileSystemMapping="true"/>
<!-- ... your other settings ... -->
</system.web>
</configuration>
Hope that helps.
这篇关于ASP.NET MVC 路由与 Windows 中的保留文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!