当MS-DOS保留名称用于参数值时,IIS给出404 [英] IIS gives 404 when MS-DOS reserved names are used in parameters values
问题描述
我有一个ASP.NET Web API应用程序,我有一个带有一个字符串参数的操作,例如:
I have an ASP.NET Web API application and I have an action that takes one string parameter, such as:
[HttpGet]
public HttpResponseMessage GetById(string id)
{
// ...
}
相应注册:
config.Routes.MapHttpRoute("Resources", "api/resources/{id}", new
{
controller = "Resources",
action = "GetById"
});
现在,当有人拨打 api / resources / con 时,IIS会给出404几乎任何其他价值都可以,比如 api / resources / something 或 api / resources / nothing 。
Now, when someone calls api/resources/con, IIS gives 404. Almost any other value is OK, like api/resources/something or api/resources/nothing.
我们已查看并发现没有保留的MS-DOS设备驱动程序名称可以用作参数值。
We have looked over and found that none of the reserved MS-DOS Device Driver Names can be used as a parameter value.
这似乎是一个全球性问题,因为MSDN也有这个问题:
This appears to be a global issue, since MSDN has it too:
- http://msdn.microsoft.com/con
- http://msdn.microsoft.com/prn
- http://msdn.microsoft.com/nul
有没有办法让这些名字用作路线参数值?
Is there any way to allow these names to be used as route parameters values?
推荐答案
添加t他在Web.config中,在system.web下。
Add this in Web.config, under system.web.
<httpRuntime relaxedUrlToFileSystemMapping="true" />
这篇关于当MS-DOS保留名称用于参数值时,IIS给出404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!