ASP.NET MVC2 - Resolve Parameter Attribute in Model Binder

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();

Answers


I spoke to Brad Wilson on Twitter and he indicated that this can be achieved with the ModelMetadataProvider in the AspNet4 Futures assembly by implementing the new IMetadataAware interface on the desired types. In addition, he indicated that this functionality would be introduced in MVC 3 for both .NET 3.5 and .NET 4.0.


Need Your Help

Linking dependency to static library?

c++ mysql visual-studio-2010 build static-libraries

I have a small console application that makes use of the MySql C/C++ connector interface.

JMeter: How to retrieve Summary Report?

logging report jmeter

After a load test was done in JMeter, it closed due to some reason before I could save the summary report. Is there any way to retrieve the values now?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.