博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c#mvc路由配置动态用户名下属站点
阅读量:4678 次
发布时间:2019-06-09

本文共 445 字,大约阅读时间需要 1 分钟。

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

你可能感兴趣的文章
NABCD
查看>>
ZOJ 2850 Beautiful Meadow (简单题)
查看>>
Android开源框架ImageLoader的完美例子
查看>>
LeetCode - Best Time to Buy and Sell Stock
查看>>
java-Coculator
查看>>
499 单词计数 (Map Reduce版本)
查看>>
python笔记
查看>>
昨天用的流量有点多60M
查看>>
kafka中的消费组
查看>>
Golang的channel使用以及并发同步技巧
查看>>
【JDK源码分析】 String.join()方法解析
查看>>
【SICP练习】112 练习3.28
查看>>
python--注释
查看>>
前端资源链接 ...
查看>>
yum install ntp 报错:Error: Package: ntp-4.2.6p5-25.el7.centos.2.x86_64 (base)
查看>>
leetcode-Single Number-136
查看>>
CF715C Digit Tree
查看>>
二分法练习1
查看>>
QT 制作串口调试小助手----(小白篇)
查看>>
前端MVC实践之hellorocket——by张舒彤
查看>>