简体   繁体   中英

IgnoreRoute for PHP Site embedded in ASP.NET MVC 3

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

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

It's probably about the missing / at the end

使用此选项可忽略文件夹“博客”的路由。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM