Partager via


DevDays Seattle – Scott Hanselman

Lolcode.net – funny site with a domain-specific language that mimics IM syntax.  Actual code

MVC

When you create an MVC project, you get default code for controllers and views but nothing for the model. ASP.Net MVC lets you use nHibernate, Linq to SQL, whatever for your data access.

The URL hierarchy is a form of user interface and in MVC the .aspx extension is gone. MVC uses the URLs to do routing - it's convention over configuration, i.e. there is no big file that defines the URL namespace - it's a convention that the URL is a controller action and there should be a controller named that.

MVC is just built on top of System.Web - there is a transition to System.Web.Mvc. WebForms is still there. It's like the difference between motorcycle and mini-van - one isn't better than the other, they are just different and for different purposes.

In the controller could create a viewmodel that goes to the database and pass that to the view. Framework doesn't require a ViewModel for a Model but it's typical to do it that way.

<%: in the view does an HTML.encode whereas <%= doesn't.

Views can be done using an .aspx extension - but no code behind anymore.

Create a model and can create a view that is strongly-typed linked to the model and will generate the details view for that. Code Templates let you change the default code generated from the wizard - using T4, the VS code generation engine.

www.nerddinner.com - if you hit it from an iPhone, detects that and the controllers and models are the same but the views are different. Code at https://tinyurl.com/aspnetmvc