IgnoreRoute for PHP Site embedded in ASP.NET MVC 3

假如想象 提交于 2019-12-24 02:40:51

问题


I have an MVC 3 site with an embedded worpress blog. All the following urls are directed through MVC.

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

I also have a top level directory called Blog, which is a php wordpress blog. If I access www.mysite.com/blog/index.php the blog shows up. But all access to www.mysite.com/blog seems to get routed through MVC and produces what seems to be an unrelated error referring to System.Web.Helpers being missing (I deployed it to the bin folder so I know that is not the issue).

In the RegisterRoutes method of my Global.asax.cs file I have tried both of these lines at the top of the method, but neither seem to work.

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

Anyone have an idea?

I have included the contents of the Global.asax.cs as per Snoopy's request:

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);
    }
}

回答1:


Use this to ignore routing for the folder "Blog".

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



回答2:


Use Routes.IgnoreRoute("Blog/"); Also remember to put it first in the routing table.

It's probably about the missing / at the end



来源:https://stackoverflow.com/questions/5777417/ignoreroute-for-php-site-embedded-in-asp-net-mvc-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!