在Asp.Net Mvc中忽略路由困难

时间:2011-06-15 00:29:40

标签: asp.net-mvc asp.net-mvc-2

在IgnoreRoute方法调用之后抛出以下异常:

  

路径控制器   找不到'/anything.php'   没有实现IController。

但是,我的MvcApplication类中有以下方法:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.RouteExistingFiles = false;

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.IgnoreRoute("{*php}", new { php = @"(/?.*/)*\.php$" });

    // Some calls to routes.MapRoute occur here.
}

如果Mvc网站设置为忽略此类路由,我不确定为什么会抛出异常。此外,我正在通过在Visual Studio中点击F5然后将http://localhost:12345/替换为http://localhost:12345/anything.php来测试该网站。非常感谢任何帮助!

谢谢,

安德鲁

1 个答案:

答案 0 :(得分:0)

您是否检查过您的正则表达式以确保它与.NET兼容?

尝试使用此正则表达式替换正则表达式:

routes.IgnoreRoute("{*allphp}", new {allphp=@".*\.php(/.*)?"})