views:

31

answers:

2

Is there any way to look at all the data annotations or attributes available in Asp.net MVC? i.e. for validation we have "Required", "StringLength" etc, for Action verbs, "HttpPost", "HttpGet" etc, similarly "Bind", "MetadataType" etc.

I am kind of new to Asp.net MVC and MVC is loaded with attributes for different purposes and I don't know if there is an attribute available to do something or even whether to use an attribute to get something done. Is there any documentation of these necessary/helper/nice-to-use attributes?

A: 

Look at the classes in System.ComponentModel.DataAnnotations and System.Web.Mvc in Visual Studio's Object Browser.

SLaks
A: 

For the data annotations, check out this blog post.

For other filters (action filters, authorize filters, etc) I'm not aware of a list anywhere, but according to this article on ASP.net they implement one of four interfaces:

  1. Authorization filters – Implements the IAuthorizationFilter attribute.
  2. Action filters – Implements the IActionFilter attribute.
  3. Result filters – Implements the IResultFilter attribute.
  4. Exception filters – Implements the IExceptionFilter attribute.

The ASP.NET MVC source is available on CodePlex, so you could search it for classes that implement one of those 4 interfaces.

Jon