I am an MVC developer since ASP.NET MVC Preview 1 and my company chose me as an instructor for an MVC 2 workshop. The session will last for 3 hours and I have not yet decided about the contents of the workshop.
What would you tell about MVC 2 in 3 hours to grab and keep the people's attention?
Thanks.
You should watch some of the presentations on Channel 9. And pick some topics that they go over...
Basics
NerdDinner
It will depend of the kind of people will watch your workshop, it they are familiar with ASP.NET, ASP.NET MVC or the MVC pattern, etc.
I think that the first and bigger concept behind the MVC is the separation of concerns, and you should show it and how it can help the developers, specially with the TESTING issue.
If people are not familiar with MVC, only this part would take a good time. If they're familiar and you want to talk specifically about the version 2 of the framework, I think the bigger changes from the previous one were:
Areas
Template Helpers
DataAnnotation Attributes
Model validator
With few examples, once 3 hours is few time to get deeper in each of these points. Would be nice to develop a few app live so they can see how easy it is.
after introduction of mvc framework u can go on to include following topics
Routing (route constraints matching and custom route handlers)
Model validation and custom
validation attributes Security and authorization attributes Model
binding default model binders and writing custom model binders
custom html helpers
Take a look at 13 extensibility points of mvc
Read Steven Sanderson's book, especially the bit about glib demos that don't tell the real story.
Some people suggest Nerddinner, but why not just point them at Hansellmann's video on the subject? To be honest, you need Nerddinner to get an impression of how MVC works, and Steven Sanderson's book to get an impression of how to use MVC.
Still, I really don't think that this is a valid question, and don't know why the Stackoverflow police have not jumped on this one.
Check out some of the presentations here: http://www.asp.net/mvc
Scott Hanselman has a 73 minute one on the home page, that might be a good one to start with and mimic, as well as some of the other ones.
Why not take them through building NerdDinner? http://www.wrox.com/WileyCDA/Section/id-321793.html
Some of the Scott Hanselman videos out there on MVC are good, too, and might give you a small break from talking.
One thing I would cover is the flexibility of MVC. E.g., you have your choice of models and view languages. I would definitely cover the Spark View Engine, to give people an idea of how they can get away from code-centric (as opposed to markup-centric) view languages.
Related
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
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
I've tried a few google searches and stack over flow searches, but this is proving hard to find than I thought. I need to provide justification to management for our shop to move to ASP.NET MVC 2. The biggest help would be any enterprise level sites or major web development shops that are using ASP.NET MVC 1/2.
Does anyone have a list or link?
I know Stackoverflow uses it, but some stats such as daily views would help too. I found the Jwaala case study here: http://www.microsoft.com/casestudies/case_study_detail.aspx?casestudyid=4000006675 . Aside from that, I'm having some issues finding some professional examples.
Thanks in advance!
Just found a few more case studies:
http://www.microsoft.com/casestudies/Case_Study_Search_Results.aspx?Type=1&Keywords=mvc&LangID=46#top
Could still use more links.
If your management requires a "...but THEY're doing it!!!" justification then you have larger problems.
If you're using the "...but THEY're doing it!!!" justification then you'll likely need much better reasons.
Hate to troll, but just saying that you'll want objective and project-specific reasoning. And if by "management" you mean business-management, then they need to understand that engineering details are best left up to engineering. The Art of War by Sun Tzu is full of advice along these lines.
...and to qualify this, I'm a web-developer working on a partial rewrite of a WebForms app. I'd love to be using MVC for this project, but the actual benefit of doing so doesn't match the cost--business is business after all, and the business-case must be considered.
If you do get stuck with WebForms then you can whip it into shape (what we're doing). With ASP.NET 4.0 (or a little inheritance trickery) you can get rid of the ID renaming; by building ViewModels, domain-objects, and clean Repositories you can avoid a lot of the cruft of WebForms--we have tight, explicit control over what WebForms generates. We've shrunk the actual content of our ASPX pages and their codebehinds by at least an order of magnitude by applying best practices.
Just remember, the tools won't make you a better developer, and unless you know what you're doing or what you're working with then you won't reap the benefits.
Dell is rebuilding its page from ASP.NET Webforms into ASP.NET MVC as Phil Haack is mentioned this on his blog ;)
I can not say if they use MVC 1 or MVC 2.
It seems that MarketWatch use ASP.NET MVC with Spark View Engine as listed here :
http://sparkviewengine.com/spark-in-the-field
http://www.marketwatch.com/
also an e-commerce webiste :
http://www.fancydressoutfitters.co.uk/
Check our sites www.reifen.com and www.bonspneus.fr. They handle pretty big traffic in germany and france.
We have used ASP.NET MVC 1 on these sites and still use (and enjoy) ASP.NET on other sites. Like others said: don't just go with ASP.NET MVC because it is in some way better. It is not. There is allways a situation where I would prefer one or the other.
Additional "live" ASP.NET MVC sites (some broken links)
http://weblogs.asp.net/mikebosch/archive/2008/05/05/gallery-of-live-asp-net-mvc-sites.aspx
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...;)