Design Patterns in ASP .NET MVC Application - asp.net-mvc

Can somebody give me a link to article or name of book, where i can find something about Design Patterns in ASP .NET MVC applications? Sry if i asking for something stupid, i'm not expert in this.

I'd recommend Steven Sanderson's book for how to use MVC (probably worth waiting for the MVC 3 version which is due soon)
Otherwise I'd look at general design patterns books like Head First Design Patterns as these still apply within MVC.
Do you have a more specific question around a particular design pattern?

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 - http://www.amazon.co.uk/Pro-ASP-NET-Framework-Steven-Sanderson/dp/1430210079
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

The official Microsoft website is actually very good for this. http://www.asp.net/mvc. I actually used Rob Conery's MVC store front video to get started (http://www.asp.net/mvc/videos/aspnet-mvc-storefront-part-1-architectural-discussion-and-overview). He goes through the repository pattern and a few other good practices for MVC, it's a little outdated now in some areas as it is written in MVC 1 but a lot of the points still hold.

Dino Esposito and Andrea Saltarello have a very good explanation and demystification of the MVC pattern on their book "Microsoft .NET: Architecting Applications for the Enterprise". I've got a review of the MVC chapter of their book in my blog

Related

.net mvc book for a rails developer

I am a rails developer and I am looking for a good .Net MVC book or tutorial. I don't know where to start. Do I have to learn .Net web forms and c# first, or can I go directly through .Net MVC?
You don't necessarily have to start with Web Form; being a Rails developer, it might even be easier for you to start with ASP.NET MVC. Ultimately, each offers a very different approach to web development and your choice will depend on your specific needs. Many will argue that MVC is the better choice.. realistically, each has its place. Moreover, keep in mind that not every ASP.NET MVC web application will be built from scratch; several projects will probably end up migrating from classic ASP.NET.
C# is one of many programming languages available for use in .NET....and although I strongly suggest learning C#, you could -technically speaking- use an implementation of Ruby called 'IronRuby' to get started. Should you first learn C#? Again, it's up to you... though just as it is helpful for a Rails developer to be proficient in Ruby, being comfortable with whichever language language you choose will prove helpful in learning a new framework. More importantly, the learning curve will seem much steeper if yo try to tackle both at the same time.. C#, can certainly differ from Ruby.
Anyhow, I highly recommend PluralSight & Microsoft's Virtual Academy to get started.
As user3435091 says, you don't need to learn WebForms, that is the old school way to do web applications in ASP.NET (the book detailed below explains why, but basically it has to be with actually web apps tend to be stateless and webforms goes to the opposite direction). With ASP.NET MVC, you will find a fundamental similarity to rails, you have Models, Views and Controllers as you would expect (they both follows MVC which is an architecture), so you don't have to change the way you think today about building a web applications. The template engine MVC uses is Razor which also uses the concepts of views, partial views, layouts, helpers, helpers for ajax, etc (it uses jQuery by default too).
The hardest part to learn I think would be with ORM (you have EntityFramework and NHibernate, the .NET implementation of Java Hibernate :s ) and that C# uses attributes (similar to java annotations). Also, you are not provided with the nice rails console out of the box in .NET.
The book I used to learn ASP.NET MVC 3 (and which I can recommend) is Pro ASP.NET MVC 3 by Adam Freeman and Steven Sanderson.
Hope that helps.

Is the Nerddiner walk-through suitable for ASP.NET MVC 2?

I'm keen to teach myself ASP.NET MVC 2 (coming from a heavy embedded or rich GUI background). If have found the nerddiner walk-through but it is still for ASP.NET MVC 1. The codeplex downloads have been updated to MVC 2 but the link for the PDF goes back to the MVC 1 book.
Is it even possible to follow the walk-through in MVC 2?
If so, what technologies does it skip? (e.g. LinqToSql instead of EF?)
Is there an updated PDF (other than getting the whole Professional ASP.NET MVC 2 book)?
EDIT - the answer seems to be universally that the v1 tutorial is good enough for learning v2. As it happened, I downloaded the sample chapter of the new book from Amazon onto my Kindle DX and found that the tutorial has been updated to EF. Because I don't personally like learning something (e.g. LinqToSql) that has been superseded - I've clicked "Buy" - Damn you Amazon for making it so easy to spend my money :-)
There's no updated PDF version but the MVC 2 version of the book is coming out this might be updated.....
However if you go through the nerd dinner walk through 99.9% of what you read applies to MVC 2. MVC 2 just adds more functionality that won't be covered but there's plenty of blogs around that cover MVC 2 functionality - check out Scott Guthrie or Phil Haack for details.
As far as technologies skipped the nerd dinner PDF uses LinqToSql whereas the MVC 2 sample uses Entity Framework. Both are valid forms of data access and are similar so if you start on LinqToSql you probably will pick up Entity Framework easily.
I did exactly what you want to do and it worked fine. Nerd Dinner is a great place to start if you are trying to learn MVC. All of the fundamentals are there and you won't miss too much. What you will find after finishing Nerd Dinner is that is will give you a great understanding of MVC but you will want to go to the next level and learn more. So even though Nerd Dinner is not MVC 2, it is one of the best tutorials I found to learn the basics of MVC in general.
So to answer your questions:
Yes, you definitely can go through Nerd Dinner with MVC 2
I wouldn't worry too much about what is missing if you are just learning, just go through it and things will become clear and you will have many more questions after that
I don't know if there is an updated version of the pdf but I would rather doubt it. I think Nerd Dinner was designed as a starting point to learn MVC.

Recommendations for learning ASP.NET MVC from a desktop developer's perspective

One of my New Year's Resolutions is to finally learn some web development. I've decided on ASP.NET MVC as I'm a believer in TDD and IoC. I'm looking for a list of topics and perhaps an order to learn them for what I'll need to know to be a solid ASP.NET MVC developer. Perhaps this is embarassing, but the only web experience I have was html pages I made using WYSIWYG editors 5+ years ago when I was in college.
So first, congratulations on picking ASP.NET MVC. I dare say that ASP.NET MVC is easier to work with than WebForms. WebForms tends to take somewhat of a "black-box" approach to the web and treat it more like classic WinForms development. WebForms would probably be a slightly more comfortable technology for you (coming from WinForms development) but MVC will leave you with a greater understanding of how the web works, which is incredibly important.
Before you dive into ASP.NET MVC, you may want to brush up on the basics of HTTP, because it is important to understand when you starting writing action methods that respond differently based on request verbs. It's also nice to know exactly what HTTP headers are, and how they can be leveraged in your application. Anyway, here's my list for you:
Important People and Their Blogs
Phil Haack: He is the lead developer on ASP.NET MVC, and his blog has tons of neat tricks and tips for using it.
Scott Hanselman: He worked with the team on NerdDinner and from time to time his blog has some neat MVC stuff.
Rob Conery: Rob's an avid promoter of ASP.NET MVC and an active open-source contributor. He has tons of code on github for you to browse for inspiration/guidance, and he also has tons of screencasts on his blog and on his business website, TekPub. I recommend purchasing his screencasts from TekPub because he's just an amazing presenter and makes understanding ASP.NET MVC so easy.
Scott Guthrie: He wrote the first chapter with respects to NerdDinner in the Professional ASP.NET MVC 1.0 book, and he always has some cool posts about new features coming in ASP.NET MVC.
Steven Walther: It seems like every time I look at his blog he's got another cool trick or code snippet related to ASP.NET MVC. He's also written a book on ASP.NET MVC that has some pretty good reviews on Amazon.
Reading Material
WDVL: HyperText Transfer Protocol: Again, this is your HTTP tutorial. I've read through part of it and it seems pretty decent. You don't need a rock solid understanding of HTTP, but a general overview of request verbs and headers specifically will help you.
NerdDinner.com Tutorial: This is lengthy step-by-step guide written by ScottGu himself about how to create a basic ASP.NET MVC website from beginning to end.
Profesional ASP.NET MVC 1.0: This is a book by the team that wrote this ASP.NET MVC, and it really does a great job of explaining the framework.
ASP.NET MVC Framework Unleashed: This is Steven Walther's book on the framework. It has some decent reviews on Amazon, though I've never read it myself, so I couldn't really give my opinion one way or the other.
Screencasts
Rob Conery's MVC Storefront Series: These screencasts are amazingly helpful. In the beginning they were working against pre-release copies of the MVC framework, so some stuff has changed, but they're still amazing material for learning ASP.NET MVC.
Scott Guthrie's Presentations on ASP.NET MVC 2: Look at the ASP.NET MVC section of this page. There are some really neat new features coming in ASP.NET MVC 2, and Scott actually builds a good foundation from the ground up with this presentation. He takes you through beginner stuff first and then shows the neat new tricks later.
Phil Haack's MIX09 MVC Session: Great content here straight from the man himself. Phil's actually a great presenter, and there's a lot of good content here.
Phil Haack's MIX09 Advanced MVC Session: Some more advanced stuff and neat tricks from Phil.
Scott Hanselman's File -> New Company MIX09 Session: I actually attended this session while I was at MIX09, and Scott's a great presenter. Well worth a gander :)
Rob Conery and Steven Sanderson TekPub Screencasts: These aren't free, but they're worth every penny. Rob and Steven are amazing teachers, and I can't recommend TekPub screencasts enough. They are top-notch.
IoC and Dependency Injection
Since you mentioned IoC specifically in your OP, there are a few libraries and blog posts that might help you with that:
Simone Chiaretta: How to use Ninject 2 with ASP.NET MVC: I actually use Ninject in my own personal projects, so this is a great resource if you're a fan of Ninject.
Rob Conery's "Hana" Source Code: Sometimes I just love seeing some quality reference code. This is actually the source for Rob's blog. He was using StructureMap originally, but I think he changed recently to Ninject.Mvc.
MVC Storefront DI Screencast: Rob talks about setting up dependency injection in the MVC Storefront. This one uses StructureMap I believe.
TekPub Concepts video (free): Rob goes over the basics of IoC and DI in this video if you need a refresher. It's free too :)
Other Pertinent Web Technologies
Because you're looking to move to the web, there are other languages and technologies that you need to know as well. Below is a list of some brief tutorials to get you started, although each of these subjects could easily warrant a post as big (or bigger) than this one!
HTML: Seems silly that I'm mentioning this here, but I only mention it because there's a lot of push these days to write valid HTML. A majority of accessibility and browser incompatibility issues can be averted by having clean markup. I personally use XHTML in my sites, but any doctype will do :)
JavaScript: This is a neat language that can be used to make many web applications feel more like a desktop application (amongst other things). There are a lot of performance gains and design victories that can be had by properly leveraging JavaScript. Once you feel comfortable with JavaScript, you will probably want to make the move to a JavaScript library to make cross-browser compatibility very easy. My JavaScript library of choice is jQuery.
CSS: This is how you should be applying style to your websites. One of the biggest mistakes a lot of developers make is to make their HTML in charge of presentation (using tables for layouts [holy war], etc. etc.). Arguments and holy wars aside, CSS is a valid skill to have, and it really isn't as hard as some might have you believe :)
I know this seems like a lot, and I've probably inundated you with material to read, however I think it's important to build a solid foundation. Web development is a lot of fun when you are good at it, and it's definitely a great way to make a living! Good luck! ASP.NET MVC is a great framework, and you've made a great choice.
Oh yeah, and there are a few other things you might want to Google in your spare time. They tend to be pretty advanced, so I didn't include them here, but you will run into them when you get more involved in the web world:
AJAX: Makes your web applications perform more naturally and do things in the background.
Web Services: A universal way to exchange data on the web. For example, there are web services that provide weather forecasts and stock quotes. You can consume them and even create some of your own!
XML and JSON: These are used to describe data. When you serialize data on the web, XML and/or JSON are the conventional technologies most developers use. JSON is popular particularly because it can be consumed so nicely within JavaScript.
First step in starting MVC is going through Nerd Dinner Tutorial.
Its the simplest and quickest way to introduce you to the basics of MVC in my opinion.
Thanks
Sorry if this sounds a bit simplistic, but... The tutorials at http://asp.net/mvc, while basic, are good to get you comfortable with the framework. As is NerdDinner. I've found that if you have a development background then learning MVC is not that big of a stretch, so long as you can grasp the MVC pattern which is pretty straight-forward. It'll be more effort to get the web interface side of things up to speed. Your best bet would be to get comfortable with HTML, JavaScript (and AJAX), and CSS so that you can produce a good interface (view).
And the obligatory "learn jQuery" for your web UI.
Get the Nerd Dinner here :
http://aspnetmvcbook.s3.amazonaws.com/aspnetmvc-nerdinner_v1.pdf
It is one of the best resources I have used so far
I would start with the following book:
Pro ASP.NET MVC Framework
alt text http://www.apress.com/resource/bookcover/9781430210078?size=medium
It contains great information on starting MVC development from scratch. The sports store example includes much more useful information than Nerd Dinner IMO.
Check out the ASP.NET MVC in Action book and the codecampserver project that goes along with it.
I switched from Webforms to MVC for my day job I while back, and found exposing myself to Rails development, post 6pm at home :), really helpful with the transission as many of Asp.net MVC principles seem to be a direct port from Rails..... and its Rails so you will just love it anyway...;)

Is there an official ASP.NET MVC reference/example app?

I'm struggling to find a good reference application for ASP.NET MVC. By "reference", I specifically mean an application that flexes all of the framework's features in the Microsoft-sanctioned manner, such as:
Master pages
Partial views
Strongly-typed models
Authentication
Custom routes
etc...
The open source examples that are out there (CodeCampServer, SutekiShop) either add significantly to the base framework or don't use all of the baked-in features.
Have you seen Rob Connery's MVC Storefront Webcast Series?
http://www.asp.net/learn/mvc-videos/#MVCStorefrontStarterKit
Source Code:
http://www.codeplex.com/mvcsamples/
I asked more or less the same question here: What are some projects which are examples of best practices for ASP.NET MVC?
As for official, the closest would be Rob Connery's which was mentioned.
This isn't official but you could check out Kigg:
http://www.codeplex.com/Kigg
It's a sizable Asp.net MVC Digg-clone with some decent code in it. Used on dotnetshoutout.com
I would consider the Nerd Dinner MVC reference app: http://nerddinner.codeplex.com/ for people just starting
While this might be a little late to the show, I believe that the ASP.net team would like people to start using the MVC Music Store as the official mvc reference example. The Music Store application is using the Razor view engine with Entity Framework's code first approach (also demonstrates database first) along with examples of dependency injection, test driven development, jQuery integration and getting and using NuGet packages.
A second reference example seems to be more on the cutting edge of things and is provided by the Patterns and Practices people. This is called the Silk Project and takes advantage of the latest web standards like HTML5, CSS3 and ECMAScript 5 along with modern web technologies such as jQuery, Internet Explorer 9, and ASP.NET MVC3.
These together would probably show you the newest in ASP.net MVC development along with some pretty neat ideas and examples.

What resources, outside of the Microsoft site(s), are available for learning about Form and MVC web applications?

I've found a few pages (some that even link to a number of other pages) on the Microsoft website that I bookmarked last night for reading today, but I'm curious as to other good non-Microsoft resources for discussing ASP.NET web applications, both Forms and MVC (including comparisons/contrasts between the two).
Keep your eye out on the MVC forums, read up on blogs:
Phil Haack
Scott Hanselman
Rob Conery
Simone Chiarretta
Derik Whittaker
Me :)
Jeremy Skinner
Torkel Odegaard
Steve Sanderson
There's a ton of people blogging about it. Also, check out some of the open source projects that are using it:
MvcContrib
Code Camp Server
Kigg
There's a bunch of books coming out:
Pro ASP.NET MVC by Steve Sanderson
Programming ASP.NET MVC by Alex Horovitz
Beginning ASP.NET MVC by Simone Chiaretta
Professional ASP.NET MVC by Phil Haack, Scott Hanselman, Rob Conery
ASP.NET MVC in Action by myself, Jeffrey Palermo, and Jimmy Bogard
I think you can guess which one I
recommend most :). Our book has an
early access program that allows you
to download PDFs as they're written.
</shamelessPlug>
Any thing else I should add to this list? I'm marked it as community wiki.
As a first port of call, I would use a social bookmarking network site, such as Delicious, to get a list of popular/tagged posts and sites:
ASP.NET MVC tagged bookmarks
Popular ASP.NET MVC bookmarks
Phil Haack's blog seems to be a good source. He's an insider and can tell you the tricks there are to know. In the end it all depends on how you prefer to learn - some people like videos, others prefer books. For me the best way is to learn by doing it. So take a look at Phil, go to CodePlex and find a project that uses ASP.NET MVC and look at the code. That way you'll also see how people solved their problems and what practices they followed, not only learn the rules of the framework.

Resources