我希望我的Web API控制器的路由通过配置文件(appsettings.json)动态分配。
我想也许这将是一个简单的解决方案。然而,尝试这个[不出所料]并不起作用:
private static string route = Configuration.GetValue<string>("Path");
[Route(route)]
// action
导致An attribute argument must be a constant expression, typeof expression, or array creation expression of an attribute parameter type
有可能做我想做的事吗?如果是这样,这样做的最佳做法是什么?我无法找到很多关于它的文档,并且不愿意使用我自己的HttpListener
来完成一个相对简单的目标。
答案 0 :(得分:3)
原来我是在过度思考。
在)
Startup
很容易就是馅饼。