.NET - Retrieve attribute from controller context?
Posted
by ropstah
on Stack Overflow
See other posts from Stack Overflow
or by ropstah
Published on 2010-03-29T22:47:22Z
Indexed on
2010/03/29
22:53 UTC
Read the original article
Hit count: 235
I have a controller insert
action:
<AcceptVerbs(HttpVerbs.Post)> _
Function InsertObject(<Bind(Exclude:="Id")> <ModelBinder(GetType(CustomModelBinder))> ByVal object As SomeObject) As ActionResult
End Function
And i have a CustomModelBinder
class with a BindModel
implementation:
Public Function BindModel( _
ByVal controllerContext As System.Web.Mvc.ControllerContext, _
ByVal bindingContext As System.Web.Mvc.ModelBindingContext) As Object Implements System.Web.Mvc.IModelBinder.BindModel
For Each s In HttpContext.Current.Request.Form.Keys
HttpContext.Current.Response.Write(s & ": " & HttpContext.Current.Request.Form(s) & "<br />")
Next
HttpContext.Current.Response.End()
End Function
As you can see I have a controllerContext
and a ModelBindingContext
available.
How do I get the: <Bind(Exclude:="Id")>
part inside the BindModel
implementation?
© Stack Overflow or respective owner