我需要链接格式为http://localhost:32136/username/HomePage
例如: - https://www.facebook.com/xxxyyyy
请建议我如何构建Url的链接。我已将route.config配置为
{{1}}
答案 0 :(得分:2)
试试这个。
RouteConfig.cs
routes.MapRoute(
name: "ProfileRoute",
url: "{username}/{action}",
defaults: new { controller = "Account", action = "Profile" },
);
AccountController.cs
public ActionResult Profile(string username)
{
if(username != "Vinoth")
return HttpNotFound();
return View(username);
}