ASP.NET MVC2 - Resolve Parameter Attribute in Model Binder
- by Nathan Taylor
Given an action like:
public ActionResult DoStuff([CustomAttribute("foo")]string value) {
// ...
}
Is there any way to resolve the instance of value's CustomAttribute within a ModelBinder? I was looking at the MVC sources and chances are I'm just doing it wrong, but when I tried to replicate their code which retrieves the BindAttribute for a complex model, calling GetAttributes() did not return the attribute I am looking for.
DefaultModelBinder
GetTypeDescriptor(controllerContext, bindingContext).GetAttributes();