c#mvc路由配置动态用户名下属站点
1.
App_Start\RouteConfig.cs
routes.MapRoute(
name: "User",
url: "User/{username}/{action}",
defaults: new { controller = "User", action = "Index", username = UrlParameter.Optional },
namespaces: new string[] { "Web.Controllers" }
);
2.
Web.Controllers.UserController:Controller
public ActionResult Index(){return View();}
3.
Views\User\Index.cshtml
4.测试
http://localhost/User/aaa/Index