Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

10-4 Episode 37: Leveraging Model Metadata and Validation with ASP.NET MVC2

21 minutes, 20 seconds


Right click “Save as…”

In this episode of 10-4, we discuss a new feature coming in the next release of ASP.NET MVC: model metadata and validation. This allows you to associate validation rules and metadata with your model and have the runtime perform validation automatically. In addition, you can also have JavaScript emitted that will provide client-side validation as well, making it dead simple to achieve a rich client and server validation experience with any web application.

For more 10-4 episodes, be sure to visit: https://channel9.msdn.com/shows/10-4

Visual Studio Topic Area on Channel 9: https://channel9.msdn.com/VisualStudio

10-4! Over and out!


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • I like it, but is there a way to create a user friendly message for the REGEXP validation?

  • DatSureDatSure He who play in root kill tree. - Sun Tsu

    Ditto on the RegEx validation question.  Great presentation and awesome technology!

  • Great question, and fortunately the answer is yes Smiley I tried to keep the video short, so I couldn't go into every scenario, but all of the validation messages can be customized, as well as localized by using resource files. In the video I just simply used the default messages for example.

  • In your demo you had a reference to jquery.validation? How easy to use it on the client-side?

  • The client-side validation that MVC uses is fully extensible, and it's pretty simple to wire-up a custom implementation. Out of the box, the validation uses MS AJAX, and if you want to use jQuery validation, there is an implementation of that in the MVC futures project (here). If you have any troubles getting it to work, feel free to e-mail me (joncart at microsoft dot com).

  • This handles formatting validation well.  Could I add a custom validation?  For example, can I verify that a new airport code is unique in the database?  Does that belong somewhere else?

  • Hi,

    I’ve just started a new project in ASP.net 4.0 with MVC 2.

    What I need to be able to do is have a custom hook at the start and end of each action of the controller.


    public void Index() {
        *** call to the start custom hook to externalfile.cs (is empty so does nothing)

        ViewData["welcomeMessage"] = "Hello World";

        *** call to the end custom hook to externalfile.cs (changes "Hello World!" to "Hi World")

        return View();

    The View then see welcomeMessage as “Hi World” after being changed in the custom hook.

    The custom hook would need to be in an external file and not change the “core” compiled code. This causes a problem as with my limited knowledge ASP.net MVC has to be compiled.

    Does anyone have any advice on how this can be achieved?

    Thankscomputerslanditcomputer computerslookup laptop video card sevenwebhosting.org

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.