c#mvc路由配置动态用户名下属站点

it2022-05-09  29

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

 

转载于:https://www.cnblogs.com/ijunxiong/articles/7248567.html


最新回复(0)