难度忽略路由在Asp.Net的mvc [英] Difficulty Ignoring Route In Asp.Net Mvc

查看:228
本文介绍了难度忽略路由在Asp.Net的mvc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是IgnoreRoute方法调用后,以下异常被抛出:

The following exception is being thrown after an IgnoreRoute method call:

有关路径控制器
  /anything.php没有被发现或不
  没有实现一个IController。

The controller for path '/anything.php' was not found or does not implement IController.

不过,我有以下方法在我MvcApplication类:

However, I have the following method in my MvcApplication class:

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测试网站://本地主机:12345 / 通过的http://本地主机:12345 / anything.php 。任何帮助深表AP preciated!

I'm not really sure why the exception is being thrown if the Mvc website is set up to ignore such routes. Also, I'm testing the site by hitting F5 in Visual Studio and then replacing http://localhost:12345/ by http://localhost:12345/anything.php. Any help is much appreciated!

谢谢,

安德鲁

推荐答案

你检查你的常规的前pression,以确保它的.Net兼容吗?

Have you checked your regular expression to make sure it's .NET compatible?

尝试用这个表达式替换你的正则表达式:

Try replacing your regex with this regex:

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

这篇关于难度忽略路由在Asp.Net的mvc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆