Accessing custom attribute DescriptionAttribute on RouteAttribute

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Accessing custom attribute DescriptionAttribute on RouteAttribute



I've added a DescriptionAttribute on the RouteAttribute in my API solution with the hopes that I can retrieve the information programmatically as part of Controller function. For example:


[Route("api/users/filter"), Description("Search for users that match filter")]



I haven't been able to figure out how to access it however. I have looked at several posts in SO that provide guidance but I am unsure how to use those with a RouteAttribute.



Using Visual Studio debug I was able to drill into the RouteAttribute entry and see the value:



(new
System.Collections.Generic.Mscorlib_CollectionDebugView((new
System.Collections.Generic.Mscorlib_CollectionDebugView(((System.Web.Http.Controllers.ReflectedHttpActionDescriptor)((System.Web.Http.Controllers.HttpActionDescriptor)(new
System.Collections.Generic.Mscorlib_DictionaryValueCollectionDebugView(item.Route.DataTokens.Values).Items[0]))[0]).MethodInfo.CustomAttributes).Items[1]).ConstructorArguments).Items[0]).Value



Unfortunately this is inaccessible due to it's protection level. Is there a way to get to this information?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard