.Net core路由高级用法

这里是我们现在用的默认路由,但是在使用当中也有麻烦。总而言之 用的不爽。

 

 

使用属性路由:RouteAttribute特性

.Net core路由高级用法

默认的HomeController下面的Index访问url路径是: home/index

但是有时候我不想这么干我就想装个B咋办

ok很简单index代码更改如下

 

        [Route("zhuangb/index")]
        public IActionResult Index()
        {
            return View();
        }

这样就可以访问 zhuangb/index了

.Net core路由高级用法

 

标记替换

可以使用标记替换

.Net core路由高级用法

.Net core路由高级用法

.Net core路由高级用法

 

.Net core路由高级用法

 

 

 

路由模板参数

https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/routing?view=aspnetcore-2.1#route-template-reference

相关文章:

  • 2021-11-02
  • 2021-08-26
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2021-08-05
  • 2021-06-13
  • 2021-08-06
  • 2022-01-01
相关资源
相似解决方案