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.
Related
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.
I just need some guidance. I'm fairly new to MVC3 and to web development in general. I want to create my own project that will involve data storage/access (SQL server db) and user log in functionality. I'm not sure were to start, there seem to be so many ways for this and following tutorials doesn't really give the experience of setting up real life project (or its just my impression). Would you guys suggest starting from an empty MVC3 project, or perhaps use the scaffolding feature and build on top of it and use the membership provider built into it ? Some tutorials (by Scott Hanselman) actually explain how to copy and paste the membership feature into a new project. Is this approach suggested ? Any suggestions will help! Thanks!
Here are some tutorials
MVC 3 with razor
ASP.Net website
MVC Music Store
Strongly typed helpers in mvc
Brad Wilson's Blog
MVC Subdomain routing
MVC Partial Views
Some javascript for MVC
MVC Javascript frameworks
JSON and MVC
Form update using JSON in MVC
I'm just starting too, I found this very helpful, especially the videos on the left.
But what I found extremely helpful is the MVC Music Store and the Contoso University site (I recommend to download as PDF; you can see a button to do so at the top).
The NerdDinner tutorial is a great way to start with ASP.NET MVC, although the online version is slightly out of date. However, I can strongly recommend the book that this tutorial (in its updated version) is the first chapter of: Professional ASP.NET MVC 3.
I always used asp.net webforms with the MVP pattern, it works great for what I need, I basically create a project where all my business rules reside, validation etc... and I then implement my views in the webforms project.
Now we're starting to use asp.net MVC and using the MVP patter doesn't make much sense, right? So what could be a good approach to create a scalable and testable project using MVC that won't make me create my data objects and do validation on the controllers. I don' want to have the same code in different places...
If a web user wants to update his/her profile on the site, there would be some validation rules for when a submit button is pushed, like email address cannot be empty, must be valid and must not exist in the database.
These same rules should be applied if I try to update his profile using the internal admin section without having to duplicate the code there...
If you can point me to a good sample project that deals with this would be great!
Thanks in advance!
You should use the MVC pattern with ASP.Net MVC.
The NerdDinner tutorial is a pretty detailed example for MVC, you can also get a book that includes the tutorial (you might want to wait for the version that covers ASP.Net MVC 3). There are plenty of resources on Microsoft's ASP.Net site.
You can always consult Google.
ASP .NET MVC was built with the Model-View-Controller (MVC) pattern in mind. That would be the pattern you'd want to use.
In addition to the resources magnifico provided, I know others have recommended the some other tutorials. I don't know if these have been updated to the latest version of the framework, but they should still serve as decent beginners.
MVC Storefront series
MVC Music Store
Also the Microsoft Patterns & Practices group recently released Project Silk which gets into more advanced techniques involving a lot of AJAX management of the UI. There's interesting stuff there.
I am looking for best practices for using Razor with MVC 3. Now what I am hoping for is some type of article, not just a list of your professed best practices, but if you have any feel free to post them.
Why is this SO worthy? It seems hard to find info on how to best use Razor with MVC views. I know about the typical MVC best practices, I am looking for Razor specific ones. Those who use Razor know that its more than a token replacer. I want to know more about how you setup the site templates using Razor.
Like I said, I am looking for a good resource on the subject.
have you ever heard of Nerddinner.com? that website has been created with ASP.NET MVC an it is open source on codeplex.
Here is the release that has razor and MVC3 version of it;
http://nerddinner.codeplex.com/SourceControl/changeset/changes/55257
You could download the source code and play with it.
Edit :
Also have a look at below blog posts;
ASP.NET MVC 3: Layouts and Sections with Razor
ASP.NET MVC 3: Implicit and Explicit code nuggets with Razor
Deployment of ASP.Net MVC 3 RC 2 Application on a Shared Hosting Environment Without Begging The Hosting Company
ASP.NET MVC 3: Layouts with Razor
Razor Releated posts on Phil Haacked's Blog
Razor syntax is not all that you are looking for, you want the best patterns and practices with using MVC 3 as well. It is a shame there are Zero books out on MVC3, only web references with vary from small to large degree. At this point you must use stackoverflow and constantly use google and set a date range to search past month or so. Also, setup a google "alert" on mvc 3 razor etc..
I find that pluralsight examples, nerddinner, Silk (MileageStats), MvcMusicStore, ProDinner, and several others to be "useful" yet not one is (or can be) the best practices in every area. Everyone tries the "happy path" but many of the example veer from this. Many examples are doing various IOC containers. Some use Unity others Structuremap, others Ninject. Depending on skill level and existing knowledge, it can be overwhelming.
Personally I'm on a new project with vs 2010 / mvc3 with Oracle 9... Thus MOST of the examples are not terribly helpful as the database integration with EntityFramework use datacontext / IQueryable is great and all, but with Oracle EF in beta, and sprocs not even working with Oracle 9 with EF (per trying , and email responses from Oracle trainers etc..) I end up having to go old school and retrofit ADO.NET and convert to List ... and use IEnumerable. Thus many of the things stubbed out for easy use in the models/controllers/views in the demo projects are half in vain for me with my environment with Oracle.
Well... I use MVC 2 and work and MVC 3 at home and I really haven't found too many differences in terms of best practices for the Razor syntax. I generally just read ScottGu's or Phil Haack's blogs if I want to read about ways to use the features of Razor. Not sure if that helps you any but I am drawing a blank.
Please check below link for example with good presentation.
http://dotnetautor.de/blog/content/binary/Windows-Live-Writer/32ee537b2c00_E16A/MVC3.pdf
I aim to try use DevExpress web server controls (which are awesome) in an ASP.NET MVC project (some articles I read on 'net seems to indicate the two can work well together).
I'm eager to start a new project using ASP.NET MVC, and I have been reading up a lot on ASP.NET MVC lately, but I'm not sure if I should invest a project in it. My concern is that it may turn out to be like LINQ to SQL, which is essentially been killed off since MS will not be providing updates.
Is ASP.NET MVC a viable solution to invest in my case?
Yes definitely ASP.NET MVC or any other MVC framework is worth learning. MVC pattern is all about seperation of concerns and helps you to keep your code clean.
If you like Devexpress control too much you could be disappointed because there is no server side control in ASP.NET MVC. But if you want to learn Web's underlying mechanism,HTML, Javascript , clean code, TDD ASP.NET MVC is a good way to go.
Learn first, experiment later
Asp.net MVC is a great development platform for building web applications, so it's definitely worth your time to learn it through and through.
But I suggest you first learn MVC framework and build at least one semi complex app with it and then start experimenting with mixing MVC with web forms controls. It is possible but as much you think you will gain you'll probably loose more. So I would be a bit reluctant and advise you not to match these. At least not on a Greenfield project.
In other words: presumably knowing Asp.net web forms would you suggest someone to heavy use dynamicly created user controls in their web pages if they're just about to learn the technology of Asp.net web forms? Probably not. Or mixing web forms with ASP pages on a greenfield project...
Instead try finding great either MVC-friendly server extensions or client-side libraries that will help you create rich web apps like ExtJS (I don't work for ExtJS llc, but I used the lib on a project in the past and liked it a lot). Using something like this you won't loose stuff from MVC and gain great user experience and rich functionality.
Seeing how you're asking the question on this site, I'd say YES!
DevExpress has a bunch of MVC specialized controls, that use Ajax to get data from the server via callbacks. You can see demos of the controls here:
http://mvc.devexpress.com.
I am not sure if you can use the web forms controls, my understanding is that you can't.
Also, regarding LinqToSql, you don't have to use that. I am using NHibernate for the data layer and it works very nice with MVC.
I worked with asp.net and web forms for more than 5 years and at least 1 year with the DevExpress controls for asp.net, but now I love MVC so much that I think I don't want to go back to the web forms anytime soon.
Hope this helped.