Pro ASP.NET MVC Framework (Expert's Voice in .NET)

Category: Programming
Author: Steven Sanderson
All Stack Overflow 30
This Year Stack Overflow 4
This Month Stack Overflow 1


by anonymous   2019-07-21

I recomend you to read some book: You need to use action parameters.

by anonymous   2019-07-21

MVC itself is a design pattern. You can use several combinations of other design patterns in your application to suit your particular needs.

If you want a read an excellent book on ASP.NET MVC then I would recommend Steven Sanderson's book -

Note: This book is available for MVC2 as well, but I have not read that one. This book uses several good concepts that will help you create a production ASP.NET MVC application including TDD, repository pattern etc

by anonymous   2019-07-21

There is no magic that you are missing. The Microsoft 'unobtrusive validation' script can be used in any website that uses jquery and jquery validate. It is not tied to ASP.NET - as long as the HTML is the format that the unobtrusive script expects, then the script will work. This fiddle shows the unobtrusive script applied to a form not produced by ASP.NET.

The unobtrusive script has two main tasks:

  1. Initialize the jquery.validate.js plugin
  2. Read the data-val* attributes in the markup and translate this into jquery validate rules

As you may have read, the markup attributes that the unobtrusive script reads are as follows


so a input field might look like this

     data-val-required="This field is required..." 
     data-val-number="Please enter a number..."
     data-val-range="Must be between 50 and 100...",
     type="text" value="" />

My personal opinion of the unobtrusive script is that it falls into the category of what Steve Sanderson calls 'demoware' in his MVC book. It does some nice stuff out of the box but it hobbles jquery validate which is much easier to use on its own. I tend to delete it when I start a new project.

by anonymous   2019-07-21

I'm reading a great ASP.NET MVC book by Apress:

In Chapter 10, there is a section called "Implementing a Custom View Engine", which shows you step by step how to implement an XSLT view engine. Its actually pretty simple (wish I could post it, but don't want to violate copyright).

I highly recommend this book to anyone (I bought and downloaded the e-book on their web site), the author really explains things well. ... OTOH, I recommend you avoid those red books with the authors' mug shots on them... unless you like books that consist mainly of screen shots and code dumps, with little effort on explaining concepts clearly.

by anonymous   2017-08-20

Had this problem when following the Pro ASP.NET MVC Framework book, added


to the routes in the global.asax.cs file and it works. See more here: serving favicon.

by anonymous   2017-08-20

quoted varbatim from an accepted answer here on SO. makes sense to me:

Must ASP.NET MVC Controller Methods Return ActionResult?

You can absolutely use specific return types, even though most examples on the web seems to return the ActionResult. The only time I would return the ActionResult class is when different paths of the action method returns different subtypes.

Steven Sanderson also recommends returning specific types in his book Pro ASP.NET MVC Framework. Take a look at the quote below:

"This action method specifically declares that it returns an instance of ViewResult. It would work just the same if instead the method return type was ActionResult (the base class for all action results). In fact, some ASP.NET MVC programmers declare all their action methods as returning a nonspecific ActionResult, even if they know for sure that it will always return one particular subclass. However, it's a well-established principle in object-oriented programming that methods should return the most specific type they can (as well as accepting the most general parameter types they can). Following this principle maximizes convenience and flexibility for code that calls your method, such as your unit tests."

see also:

by anonymous   2017-08-20

I asked a similar question yesterday. Maybe you want to check out Preserve data in .net mvc

following is the code copied from Steve Sanderson's book

public static class PagingHelpers
    public static string PageLinks(this HtmlHelper html, int currentPage,
    int totalPages, Func<int, string> pageUrl)
        StringBuilder result = new StringBuilder();
        for (int i = 1; i <= totalPages; i++)
            TagBuilder tag = new TagBuilder("a"); // Construct an <a> tag

            tag.MergeAttribute("href", pageUrl(i));
            tag.InnerHtml = i.ToString();
            if (i == currentPage)

        return result.ToString();
by anonymous   2017-08-20

I recommend getting a book on ASP.NET MVC and working through the examples in the book. Don't worry too much about the history of the MVC design pattern or it's 1979 roots at Xerox PARC. I wouldn't bother reading much more about the actual MVC pattern than this simple article from MSDN: Cutting Edge: ASP.NET Presentation Patterns

I recently finished Steve Sanderson's Pro ASP.NET MVC Framework and I can recommend it. It has a multiple chapter sample application that gets you started quickly with ASP.NET MVC and then 10 or so follow-up chapters that cover the relevant topics in depth (Controllers, Views, Security, etc). The book has a strong focus on unit testing and dependency injection and also covers basic object relational mapping with LINQ to SQL. There is also chapters that cover integrating jQuery with ASP.NET MVC and how you might utilize framework components (authorization, membership, roles, personalization, caching, etc) from traditional WebForms applications.

There are a number of positive reviews on Steve's Blog which is also a good source of additional ASP.NET information. has a couple of positive reviews on the book (I need to add mine when I get some free time). You can also preview some of the book over at Google Books.

Some of the other books that are available now or available shortly are:

Wrox: Beginning ASP.NET MVC 1.0 --- Both authors Keyvan Nayyeri and Simone Chiaretta are active ASP.NET MVC bloggers. There is a sample chapter on testing for download here. I've read that it should be available at the end of June 2009?

Manning: ASP.NET MVC in Action --- This book is by Ben Scheirman, Jeffrey Palermo and Jimmy Bogard. They all have interesting blogs that cover ASP.NET MVC related topics. If I heard correctly, this book should be out in August 2009. You can pre-order the book (MEAP = Manning Early Access Program) here and get access to the first 11 chapters (unedited or loosely edited I think). The CodeCampServer reference application that complements the book is pretty intense and covers using nHibernate (ORM), Castle Windsor (DI / IoC), DDD, unit, integration and regression testing.

Wrox: Professional ASP.NET MVC 1.0 --- This is the book that accompanies the NerdDinner sample application and reader that was made available a while back. It's authored by some pretty smart Microsoft guys: Rob Conery, Scott Guthrie, Scott Hanselmann and Phil Haaaaaaaaaaaaack who have the inside information on why certain decisions were made with the framework. Available now.

Packt: ASP.NET MVC 1.0 Quickly --- The author Maarten Balliauw has a pretty good blog that talks about various ASP.NET MVC issues including testing. Available now.

Sams: ASP.NET MVC Framework Unleashed --- Author Stephen Walther is responsible for a number of popular ASP.NET Unleashed books from the early 1.0 days of ASP.NET and now he is writing a book on ASP.NET MVC. You can check out his blog for sample content from the upcoming book and other ASP.NET MVC related posts. Amazon says this book will be available in July 2009.

Wrox: ASP.NET MVC Website Programming Problem Design Solution --- This appears to be a follow-up to the book Wrox: ASP.NET 2.0 Website Programming: Problem Design Solution and welcomes back author Marco Bellinaso and introduces two new authors to the project Nick Berardi and Al Katawazi. The sample application for the book is the Beerhouse CMS and is available for download on CodePlex. The book's website says that it will be released in June 2009.

by anonymous   2017-08-20

Roy - You ask a good question.

In my experience, the best resource that addresses your question is Chapter 12 of Steven Sanderson's Pro ASP.NET MVC Framework book.

I'm eager to see others respond to this question too.