【问题标题】:C# MVC dynamic Route based on config基于配置的 C# MVC 动态路由
【发布时间】:2019-03-13 05:36:14
【问题描述】:

是否可以有一个动态路由名称,以便可以从配置文件中读取路由名称?

例如其中 someStringReadFromConfig 将从配置文件中填充。

[Route("api/v1/test/"+ someStringReadFromConfig +")]
public class TestController : Controller
{
    public TestController()
    {
    }
}

【问题讨论】:

    标签: c# asp.net-mvc-4 asp.net-web-api routes asp.net-web-api-routing


    【解决方案1】:
     **You can simply add **`routes.MapMvcAttributeRoutes();` 
    

    添加你的代码

    [Route("api/v1/test/"+ someStringReadFromConfig +")]
    public class TestController : Controller
    {
    public TestController()
    {
    }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-26
      • 2010-09-22
      • 2020-10-09
      • 2023-02-22
      相关资源
      最近更新 更多