Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可以在 C# web api 控制器中读取路由前缀值。我试过了,但我找不到任何方法来访问它。
[RoutePrefix("api/Account")]
如何将内部的值放入""变量中。
""
RoutePrefix是常规的 .NET 属性,因此您可以像这样访问它(假设您是从控制器内部执行此操作):
RoutePrefix
// this.GetType() is type of current controller var prefix = this.GetType().GetCustomAttribute<RoutePrefixAttribute>().Prefix;