【问题标题】:IgnoreRoute for PHP Site embedded in ASP.NET MVC 3IgnoreRoute for PHP Site 嵌入在 ASP.NET MVC 3 中
【发布时间】:2011-08-12 06:07:15
【问题描述】:

我有一个带有嵌入式 worpress 博客的 MVC 3 站点。以下所有 url 都是通过 MVC 定向的。

www.mysite.com
www.mysite.com/aboutus
www.mysite.com/contactus 

我还有一个名为 Blog 的顶级目录,它是一个 php wordpress 博客。如果我访问www.mysite.com/blog/index.php,就会出现博客。但是对www.mysite.com/blog 的所有访问似乎都是通过MVC 路由的,并产生了一个似乎与System.Web.Helpers 丢失无关的错误(我将它部署到bin 文件夹,所以我知道这不是问题)。

在我的Global.asax.cs 文件的RegisterRoutes 方法中,我在方法的顶部尝试了这两行,但似乎都不起作用。

routes.IgnoreRoute("Blog");
routes.IgnoreRoute("{folder}/{*pathinfo}", new { folder = "Blog" });

有人有想法吗?

根据史努比的要求,我已包含 Global.asax.cs 的内容:

public class MvcApplication : System.Web.HttpApplication
{
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("Blog");
        routes.IgnoreRoute("{folder}/{*pathinfo}", new { folder = "Blog" });
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

    }

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);
    }
}

【问题讨论】:

  • 请发布您的完整注册路线。

标签: php asp.net iis asp.net-mvc-3 ignoreroute


【解决方案1】:

使用Routes.IgnoreRoute("Blog/");也记得放在路由表的首位。

这可能是关于最后缺少的/

【讨论】:

    【解决方案2】:

    使用它来忽略文件夹“博客”的路由。

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

    【讨论】:

    • 运气好了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 2010-10-22
    • 1970-01-01
    • 2011-12-29
    • 2011-03-16
    • 1970-01-01
    相关资源
    最近更新 更多