问题
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