1
我在我的應用程序下面的路由:MVC - URL鏈接
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(null, "{article}",
new { controller = "Home", action = "Article" });
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
這使得我的網址,以文章看起來像這樣(例子),它工作正常:
www.website.com/article-example-1
www.website.com/funny-photos-of-the-day
www.website.com/something-about-dogs
www.website.com/how-to-repair-car
等。
但是我從另一個控制器的視圖有問題。例如從管理器視圖時我添加URL鏈接,這樣的:
<a href="article-example-1">Article example 1</a>
那麼它重定向我不要:
www.website.com/article-example-1
但到:
www.website.com/Administrator/article-example-1
如何使鏈接指向正確的鏈接(沒有控制器在URL中)。