ASP.NET MVC2 - Resolve Parameter Attribute in Model Binder
Posted
by Nathan Taylor
on Stack Overflow
See other posts from Stack Overflow
or by Nathan Taylor
Published on 2010-02-26T19:54:03Z
Indexed on
2010/04/03
6:53 UTC
Read the original article
Hit count: 458
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();
© Stack Overflow or respective owner