c# - Custom Attribute for the route -


I want to create a custom attribute, for the parameters in my path I can not use the "parameterbugging attribute"

Before "do something", I want to verify the parameter myVar

how to do this? Get the public IHttpActionResult ([myAttribute] int myVAR) {// Something}

Thanks

You can write an action filter that will inspect value.

  [VerifyMyVar] Public IHttpActionResult Get (Int myVar) {// TODO} Public Class VerifyMyVar: HttpActionFilterAttribute {...}  

If you are more specific If you want verification, you can inspect MethodInfo from the filter, and do something special with [MyAttribute] code inside.


Comments

Popular posts from this blog

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -

c# - Split String between 2 substrings without removing delimiters -

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -