Is possible to read Route Prefix value in C# web api controller. I tried out, but I couldn't find any way to access this.
[RoutePrefix("api/Account")]
How to get the value inside ""
in to a variable.
Is possible to read Route Prefix value in C# web api controller. I tried out, but I couldn't find any way to access this.
[RoutePrefix("api/Account")]
How to get the value inside ""
in to a variable.
RoutePrefix
is regular .NET attribute, so you can reach it like this (assuming you are doing that from inside of controller):
// this.GetType() is type of current controller
var prefix = this.GetType().GetCustomAttribute<RoutePrefixAttribute>().Prefix;