我的网址是这个
localhost:45678 /博客/索引
我需要这种格式的
localhost:45678 /博客
我在路由文件中写了以下代码,但是
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Blog",
url: "{Blog}",
defaults: new { controller = "Blog", action = "Index" }
);
routes.MapRoute(
name: "forblogcontent",
url: "Blog/{slug}/{id}",
defaults: new
{
controller = "Blog",
action = "DisplayContent",
slug = UrlParameter.Optional
}
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Content", action = "AddContent", id = UrlParameter.Optional }
);
}
当我单击链接按钮时,它仍然显示
localhost:45678 /博客/索引
我的链接按钮代码是
<a href="@Url.Action("Index","Blog")">Blogs</a>
该如何纠正?