2
例如,我有一个About Us
页:路由与友好的URL
htttp://localhost/About/Index
我怎么能有这个页面的用户友好的网址?
http://localhost/about-us.html
我目前的解决方法:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvc(routes =>
{
routes.MapRoute(
name: "AboutPage",
template: "about-us.html",
defaults: new {controller = "About", action = "Index"});
});
}
这是错误的方法做。如何正确映射路由,以便当我在cshtml页面中使用@Url.Action("Index", "About")
时,它会为我生成链接/about-us.html
?
到底为什么要增加一个名“.html”扩展使一些_more_人性化?对我而言,'http:// example.org/about'将是最方便用户的网址。 –