我有一个嵌入了worpress博客的MVC3站点。以下所有urls都是通过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" });有谁有主意吗?
根据Snoopy的要求,我已经包含了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);
}
}发布于 2012-01-24 18:29:51
使用此选项可以忽略文件夹"Blog“的路由。
routes.IgnoreRoute("Blog/{*pathInfo}");发布于 2014-08-04 18:37:34
使用Routes.IgnoreRoute("Blog/");也要记住将其放在路由表的第一位。
可能是关于最后丢失的/的问题
https://stackoverflow.com/questions/5777417
复制相似问题