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

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

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

sql server ce - Is there some way to make sqlce3.5 and 4.0 co-exist in the C# project -