2

我有一个非常奇怪的路由问题。

我有一个使用区域的 ASP.NET MVC 3 站点。我在资产区域设置了以下路线:

public override void RegisterArea(AreaRegistrationContext context)
{
    context.MapRoute(
        null,
        "Assets/{controller}/{action}/{code}",
        null,
        new { code = @"(\w{2,3}$)" }
    );

    context.MapRoute(
        "Assets_default",
        "Assets/{controller}/{action}/{id}",
        new { action = "Index", id = UrlParameter.Optional }
    );
}

当我请求以下 URL 时,它可以完美运行

http://site.com/Assets/Gallery/GetByCode/AEP
http://site.com/Assets/Gallery/GetByCode/MEC
http://site.com/Assets/Gallery/GetByCode/GP
http://site.com/Assets/Gallery/GetByCode/BR2 
http://site.com/Assets/Gallery/GetByCode/ZZZ 
http://site.com/Assets/Gallery/GetByCode/123

但是当我请求此 URL 时,我收到“404 - 找不到资源”错误

http://site.com/Assets/Gallery/GetByCode/PRN
http://site.com/Assets/Gallery/GetByCode/prn

我尝试过的所有其他 URL 都有效 - 似乎只是 PRN 有问题。

我在 GalleriesController > GetByCode 操作的开头设置了一个断点,并且 PRN 路由甚至没有尝试进入该操作(正如 404 错误所暗示的那样)。

有谁知道为什么 PRN 在路线中不起作用?或者我还能尝试调查什么?

感谢您的帮助萨恩

4

1 回答 1

2

This may be related to the fact that you can't create the folder "prn" on the Windows file system. My guess is IIS uses the windows file system in such a way that this issue resonates to the described problem above.

In fact, this post may help you: ASP.NET MVC Routing vs. Reserved Filenames in Windows

于 2012-09-18T09:19:07.527 回答