Scott Hanselman

ASP.NET 3.5 Extensions - plus MVC How-To Screencast

December 10, '07 Comments [59] Posted in ASP.NET | ASP.NET MVC | Microsoft | Programming | Screencasts
Sponsored By

Windows Media PlayerDarn that ScottGu, he's scooped me again. Just kidding. Around dinner time this evening we released the preview of the ASP.NET 3.5 Extensions at http://asp.net/downloads/3.5-extensions/.

Why?

Why release extensions when we JUST released Visual Studio 2008? There's kind of a sine wave thing going on. We stagger the BIG releases of things like .NET or Visual Studio with smaller releases of things like MVC or the Ajax Framework. So, release Visual Studio 2005, then release Ajax, release Visual Studio 2008, release MVC, dynamic data, new controls, etc. It's sometimes confusing (and believe me, I'm working them) but it gets you fresh stuff sooner.

Should You Fear This Release?

imageNo, it's pretty harmless. If you look in the Object Browser in Visual Studio you'll see that one assembly you already have has had some additions and its version rev'ed. You can see System.Web.Mvc there at the right.

I wouldn't go slapping it on a production machine unless you're living on the razor's edge, but it should be fine on a development machine if you know how to pay attention to what versions your projects reference.

What do I get for My Free's Worth?

Well, you get a number of things. You get (from the Gu) with my edits:

  • ASP.NET AJAX Improvements: Better browser history support (back/forward button integration, and server-side history management support), improved AJAX content linking support with permalinks
  • ASP.NET MVC: This model view controller (MVC) framework for ASP.NET provides a structured model that enables a clear separation of concerns within web applications, and makes it easier to unit test your code and support a TDD workflow.
  • ASP.NET Dynamic Data Support: New features that enable faster creation of data driven web sites.  It provides a rich scaffolding framework, and will enable rapid data driven site development using both ASP.NET WebForms and ASP.NET MVC. (This is hot...more on this soon...I demo'ed part of this at DevConnections)
  • ASP.NET Silverlight Support: Included will be new controls that make it easy to integrate Silverlight video/media and interactive content within your sites.
  • ADO.NET Data Services: In parallel with the ASP.NET Extensions release we will also be releasing the ADO.NET Entity Framework.  This provides a modeling framework that enables developers to define a conceptual model of a database schema that closely aligns to a real world view of the information.  We will also be shipping a new set of data services (codename "Astoria") that make it easy to expose REST based API endpoints from within your ASP.NET applications.

MVC How-To Video Screencast

I also (as the last bit of work before paternity leave) put together a 40 minute How-To Screencast on the MVC Framework as part of a series that myself and the team will be releasing. There will be a number of screencasts released this week on the ASP.NET 3.5 Extensions, but here's a special preview for you, Dear Reader, because you're reading this blog. You can get a WMV of my screencast here days ahead of the general public. ;) There will be a number of additional formats available in a few days up on the site, including iPod and other portable devices. I'm continuing to tweak my screencast style and I did my best to make sure this one looked good on smaller screens. Let me know.

IMPORTANT CODE UPDATE: After I recorded this video, Rob Conery updated some things in his Toolkit codebase. You'll want to change the code for the HTML Helpers to either:

<%using(Html.Form("action","controller",new{id=ViewData.ProductId})){%>

or

<%using(Html.Form<HomeController>(x=>x.Update(ViewData.ProductId))){%>

Where do I get more info?

Everywhere. Be sure to visit http://asp.net/downloads/3.5-extensions/ several times next week as there will be videos coming out every few days this week covering the whole release - not just MVC. There's a forum setup to discuss them, and Phil, ScottGu, myself and others will be blogging things, both good and bad, as we discover them.

Also, do check out Phil's blog as he's digging into some meaty topics while I'm changing diapers. He's got posts already on:

Enjoy!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Monday, December 10, 2007 5:58:58 AM UTC
Screencast! w00t! Thanks!
Brent Brown
Monday, December 10, 2007 6:00:26 AM UTC
:)
Monday, December 10, 2007 6:54:20 AM UTC
At about 8 seconds in, when you glance to the side, I wish there was a caption that said "**I step away from the mic to breathe in".
Monday, December 10, 2007 7:00:48 AM UTC
Hi Scott,

Can you make arrangements to post a little informative tutorial on using MVC with SubSonic.

I think many of us would prefer to go that way, availing best of both te worlds. Asp.Net MVC as a best option for Rails and SubSonic ( With Scaffolding and Migrations implemented) as the best option for Active Records.

Thanks

IronRuby
Monday, December 10, 2007 8:51:52 AM UTC
Fantastic - thanks for sharing this and I believe the async distribution model (ie. extensions vs. core/vs distributions) is brilliant even though it makes me feel exhausted at times ;-)
Monday, December 10, 2007 8:55:44 AM UTC
Just starting to watch the screencast. Did you do this late at night? Was everyone else in the house sleeping? It sounds like you are trying to get this done without waking anyone else. I have seen you present a few times (though I think the last time was for the 2003 launch in Portland) and you have a much stronger presence when you are at the front of the room. Here you are a bit more timid. I think for the next time around you should do this (if your home office allows) standing up. Let us feel your passion...
Monday, December 10, 2007 9:01:06 AM UTC
Hm...that's interesting and unexpected feedback. I appreciate it though. I would say that it's difficult to "feed off the energy of the room" when you're alone and talking to yourself.
Monday, December 10, 2007 9:12:47 AM UTC
And here is an unrelated comment...you went to the trouble of setting up gravatar support on this blog, yet you don't use it yourself...getting recognized on the street too much now?
Monday, December 10, 2007 9:23:04 AM UTC
Hi Scott,

Nice screencast. I rather prefer to call you the ScreenCast-Guy as you are always up with lots of wonderful videos. Anyways, im a newbie with MVC and architecture. Kindly, could you explain the difference between MVC and 3-tier patterns. Just wanted to know when to use each one of these. I hope this is the right place to ask this question.

Thanks...
DotNetGuru
Monday, December 10, 2007 9:33:27 AM UTC
Weird. I do use the Gravatar. Have for years.
Monday, December 10, 2007 9:35:03 AM UTC
Looks like the Gravatar site is having troubles.
Monday, December 10, 2007 10:48:28 AM UTC
I really appreciate that you explain what the installer will do to your system ("Should You Fear This Release?"). Sometimes I am apprehensive with installing stuff like this, so thanks!
Mike
Monday, December 10, 2007 10:51:53 AM UTC
By the way, this is a very good quality screencast, zooming etc. Great work, what software do you use? Does it output as a Flash player as well?
Mike
Monday, December 10, 2007 1:05:55 PM UTC
Fantastic!
Monday, December 10, 2007 2:47:52 PM UTC
this is incredible ! thanks Scot.
jav
Monday, December 10, 2007 4:01:11 PM UTC
Scott,

Does the Extensions preview superseed the Entity framework/tools CTPs?

Thanks,
BOb
Bob Archer
Monday, December 10, 2007 4:24:41 PM UTC
I love how you stalling while looking for the LINQ item in the "new item" dialog... Maybe it's time to finally add a little filter text box to that beast :)

I've spent last year full time in Rails and 4 years prior full time in ASP.NET, which really gives me a pretty good view on the issue (imho). As much as I hate the buzzwords of the rails world, it's time to bring them out here :)

You have mentioned the "convention over configuration" concept yourself, yet it seems that MVC team missed the mark on this one, especially when applying the DRY (dont repeat yourself).
1. unnecessary [ControllerAction], as you have pointed it out
2. unnecessary RenderView("Index") in the Index() action
3. unnecessary RouteHandler for every route, and it's the same one
4. unnecessary "action = "index"" in routes - index is default and should assume that value when missing

I'm hoping, but not holding my breath for a decent solution to the database aspect of things. This is a huge omission and is completely baffling that MS to this point has absolutely zero to offer here. LINQ is cute, but it's just a platform where a real framework is needed. The "use whatever you like" aspect that has miserably failed in ASP.NET itself won't work here either. One of the main reasons why Rails is so easy is because it makes a lot of unimportant decisions for you so that you can just start working instead of wasting time figuring out what to use.

Finally, having codebehind for the views is 1000% against the MVC architecture. Controller *IS* the code behind for a view, having another one is completely pointless and defeats the whole purpose.

I really wish MS would bring an experienced Rails developer with .NET experience on board for this one. Having one of the Castle folks look at it was a good idea, but not enough.
Alex G
Monday, December 10, 2007 5:38:20 PM UTC
Hi Scott. I think you've mentioned this before, but I would love to hear you interview Lutz Roeder. Now that you're a blue badge, is this any more possible than it was before?

I have a related question for you. My reflector recently upgraded to 5.0.50.0 after I upgraded to VS.NET 2008. I can no longer do the SHIFT+CTRL+C thing to copy code:// links. Can you? Dang. I loved that feature.

I tried to send this via the email link, but I couldn't figure out how to send Scott and email without having to pay $12 a year for an i-name.
flipdoubt
Monday, December 10, 2007 6:05:54 PM UTC
Woo Scott awfully white and scruffy looking :)

Very excellent video though! Woot!

Eric
Monday, December 10, 2007 6:26:45 PM UTC
Should this preview be working with the Express editions of Visual Studio?

I'm getting a few of the templates showing up in Web Developer, but not the MVC template, which is what I installed the thing for... Otherwise, I'll have to wait until Central IT let's me have the latest full version...
Monday, December 10, 2007 7:10:01 PM UTC
Scott, great screencast, keep up the excellent work..
Mike Kidder
Monday, December 10, 2007 7:13:45 PM UTC
Thanks for the video and the work Scott!
Eric
Monday, December 10, 2007 7:15:30 PM UTC
Josh...I'll look into the template thing, but you should be able to find the templates and make a helloworld yourself just by adding a reference to the right assembly. I'll look into getting you a jumpstart. There's nothing magical about the templates.
Monday, December 10, 2007 7:17:58 PM UTC
Ah, here's how to hook up MVC on Web Developer Express.
Monday, December 10, 2007 7:23:41 PM UTC
Hi Scott,

I hope the other formats will be lighter, 100 + MB is too big for me to see on a satellite connection.
Same for the 3.5 GB VS download for a trial!!!, beta 2 was 700 MB or so and was fine.
This is a good way to discourage people from tying a product.
I am limited to 900 MB/week.
Not everyone lives in a big city with big wires...
JPHILIP
Monday, December 10, 2007 9:04:31 PM UTC
Wow! Great video. It looks like you put a great deal of effort into the zooming. It paid off.
Mario Pareja
Monday, December 10, 2007 10:05:12 PM UTC
This is a really high quality screen cast. I'm impressed.

My one suggestion is to set your tab size to 2 so you can show more code without needing to zoom as much. I don't think readability would be impacted, so it's worth checking out.
shawn
Monday, December 10, 2007 10:20:29 PM UTC
Great work Scott much appreciated. I like how you zoom in, really saves my poor eyes.
OmegaSupreme
Monday, December 10, 2007 11:40:10 PM UTC
@Alex G

I hear ya about the "dry violations", they do feel weird and probably should be cleaned up. However, you have to remember this is C# and things are very explicit and strongly typed in that world. You can imagine these things feeling much better if you're using MVC in a dynamic language. =)

WRT the code-behind; think of them as Rails view helpers. Sure, it's a little different since view helpers have a 1-1 mapping to a controller where a code-behind has a 1-1 mapping to a template, but in the MVC pattern they both serve the same purpose: a place to put view-specific code that does not belong in a view template.

I've been a full-time Rails developer for the past couple years, so I definitely know where you're coming from. This is a huge step in the right direction though, but remember that MVC is not a clone Rails ... it is meant to give more control to the ASP.NET developer.
Tuesday, December 11, 2007 12:44:05 AM UTC
Those interim released of which you speak, the ones in-between the major VisualStudio releases, those are what are known as "catching up with the other guys" type releases. In this case trying to keep up to date with the MVC movement in web development as well as Ajax support in web development. In general terms it's what's known as, keeping up with the Jones'.
Diego
Tuesday, December 11, 2007 12:55:07 AM UTC
Thanks for the great Screencast.

After fallowing your tutorial in details I ran into the below problem.

<% using(Html.Form("Home", "Update")) { %>

The above code outputs below source code, somehow Update appeares before before Home. I never touched Global.asa.cs

<form action="/Update/Home" method=post >


So...

<% using(Html.Form("/Home", "Update/" + ViewData.ProductID)) { %>

=

<form action="/Update/1//Home" method=post >


Workaround:

<% using(Html.Form("Update/" + ViewData.ProductID, "Home")) { %>

=

<form action="/Home/Update/1" method=post >


What is the reason for this? The updated MVCToolkit which you didn't use in your screencast?
Mohamed
Tuesday, December 11, 2007 1:04:46 AM UTC
There was a bug in the code Scott was using that caused him to use a workaround. I fixed it for the release and you can write your code like this (freehanding this...):

<%using(Html.Form<HomeController>(x=>x.Update(id))){%>
...
<%}%>

or

<%using(Html.Form("action","controller",new{id=1})){%>
...
<%}%>
Tuesday, December 11, 2007 1:27:32 AM UTC
An excellent screencast - gave me something to do while I downloaded VS2008 from MSDN. :-)

I'm quite keen on ASP.Net MVC because I spent a few years before ASP.Net doing ColdFusion development with Fusebox and loved it's ease-of-use.
Rob King
Tuesday, December 11, 2007 1:56:23 AM UTC
Fantastic screen cast!

What tools did you use to put it together so quickly?
SM
Tuesday, December 11, 2007 2:55:28 AM UTC
Nice introduction for those not familiar with MVC.

I'm not quite sure that you did in fact demonstrate the 'C' in CRUD....it was more like RU.

Nice job all the same :)

Tuesday, December 11, 2007 3:15:01 AM UTC
Fantastic video, worth every second of my time to watch. Thanks for hooking us noobies up with a great demo to digest. Regards...
Tuesday, December 11, 2007 3:37:18 AM UTC
CTRL+ALT+C.

I would still like to see Scott interview Lutz.
flipdoubt
Tuesday, December 11, 2007 4:28:08 AM UTC
I really enjoyed the video. The combination video window, zooming, and red circle when you clicked made this style of screencasting very watchable. Oh yeah, MVC is great too. :)
Josh Schwartzberg
Tuesday, December 11, 2007 6:28:19 AM UTC
Very good introducation to MVC and It would be motivating the readers so that they use design patterns.I am really appriciating the articale again.
Cheers,
Shantha
Tuesday, December 11, 2007 8:05:16 AM UTC
Really excellent video, Scott. Very well done! Great intro to MVC. I hope we can look forward to more advanced examples of using MVC in the future, in particular using multiple data sources on a single page to address more real-world scenarios. Thanks for taking the time for the screencast.
Tuesday, December 11, 2007 10:00:57 AM UTC
Nice One for MVC specialy for me...
Florim Maxhuni
Tuesday, December 11, 2007 4:21:10 PM UTC
I won't lie... I fell asleep during the last quarter of the video. Don't worry it wasn't your fault. Haven't slept enough since MVC came out :)

great video!
Tuesday, December 11, 2007 4:59:41 PM UTC
+1 from this VS.NET2k8 MVC Noob. Hugely helpful; I am grateful.

-james
James McFarland
Tuesday, December 11, 2007 6:50:00 PM UTC
fantastic video, thank you!
i like how you use the zoom and the picture in picture.
Dominik
Tuesday, December 11, 2007 7:21:06 PM UTC
Nice post! Love the screencast, very thorough and yet so easy to understand :)
Tuesday, December 11, 2007 10:59:28 PM UTC
Wow... that's Rails.NET. Microsoft trying to be like the cool kids ;)
Diego
Wednesday, December 12, 2007 12:00:25 AM UTC
MVC looks very promising. Perhaps I missed something, but doesn't it rather throw out the ViewState baby with the dishwater, though?

To reiterate other viewers comments: I really like the style of the screencast. The zooming and red circles when you click are a very nice touch. I liked the Hansel-head in the corner too! ;) How do you do the zooming? I've heard/read you mention about using that in presentations before but I don't recall you describing how it's done.

Thanks,
Damian.
Damian Powell
Wednesday, December 12, 2007 9:00:47 AM UTC
That's all standard Camtasia with some post-production. I'll do a screencast about screencasts. :)
Wednesday, December 12, 2007 2:15:02 PM UTC
Hi Scott,

When you add a re router method or pattern, the framework does not create the url's correctly i.e.

RouteTable.Routes.Add(new Route
{
Url = "[controller]/[action]/[category]",
Defaults = new { action = "List", category = (string)null },
RouteHandler = typeof(MvcRouteHandler)
});

//Controller

[ControllerAction]
public void List(int category)
{
List<Product> products = northwind.GetProductsByCategoryID(category);

RenderView("ListingByCategory", products);
}

The url is simply

Products/List

and not

Products/List/Beverages

It works great with the default router of the [controller]/[action]/[id]

-----------------------------------------------------------------------------------------------

Second one, "UNIT TESTING"

In Scott G's Blog in Part 1 of the MVC, he has a type of TestViewEngine. This is not in the framework anymore from when he wrote his piece and I am not able to create one based on the framework offering. Can you tell me where I can find information regarding this elusive type as shown in Scott G's Blog?

TestViewEngine testView = new TestViewEngine();
controller.ViewFactory = testView;

Great work BTW on this, I am lapping this up lol!!

Kind regards

Andrew Rea
Orrell,
Wigan,
United Kingdom
Andrew Rea
Wednesday, December 12, 2007 2:30:02 PM UTC
Following on from the above it would appear that placing another router rule in conflicts, which meant I could not get Scott G's Ecom Showcase to work with CategoryName instead of CategoryID when viewing all products under a certain category. To solve this I had to do the following, remove this from Global.asax.cs

RouteTable.Routes.Add(new Route
{
Url = "[controller]/[action]/[id]",
Defaults = new { action = "Index", id = (string)null },
RouteHandler = typeof(MvcRouteHandler)
});

Add this part instead:

RouteTable.Routes.Add(new Route
{
Url = "[controller]/[action]/[category]",
Defaults = new { action = "List", category = (string)null, controller="Products" },
RouteHandler = typeof(MvcRouteHandler)
});

Amend my controller for the method of List to be the following:

[ControllerAction]
public void Categories()
{
List<Category> categories = northwind.GetCategories();

RenderView("Categories", categories);
}

[ControllerAction]
public void List(string category)
{
if (!String.IsNullOrEmpty(category))
{
List<Product> products = northwind.GetProductsByCategory(category);
RenderView("ListingByCategory", products);
}
else
{
Categories();
}
}

Could you explain where I am going wrong in the router pattern where by it is not recognising a custom one designed by me.

Kind Regards,

Andrew Rea
Andrew Rea
Wednesday, December 12, 2007 3:09:56 PM UTC
Hi Scott,
thanks 4 the great screencast as usual. just want to ask u whether u have other video format other than this, coz it's not working in my windows media player 10 mobile, only the sound is coming out, no video.
I qot this same problem with ur previous ALT.net screencast.
thanks :)
Wednesday, December 12, 2007 4:34:46 PM UTC
Hi Scott,

Great screen cast. Can you blog about how you created the screen cast?
Wednesday, December 12, 2007 6:15:30 PM UTC
Scott, Rob:

<%using(Html.Form("action","controller",new{id=1})){%>
-Doesnt work, object adds "id" as an html attribute to the form tag, not to the "action" url string

<%using(Html.Form<HomeController>(x=>x.Update(id))){%>
-Works fine (import the "Northwind.Controllers" namespace in page if not fully qualified)

Also, I cannot get the extension methods to work (in fact, its killing the Intellisense) if I add a tagPrefix for the Mvc.Toolkit in the web.config file as noted in the video. However, if I add it as a web reference, it works fine. Did this change, or did I mess something up??

Thanks..
Mike Kidder
Thursday, December 13, 2007 7:58:27 PM UTC
Great job Scott, thanks!
As always, it's a great pleasure to visit your blog.
I wish that it was possible to download your nice screencasts as mp4 format for my ipod touch.
Thursday, December 13, 2007 9:21:59 PM UTC
Excellent video! I can't wait to get some time to mess around with this. I hope you (or someone else) will eventually have examples with real world/complicated UIs with cascading drop downs, ajax, etc...
Daniel Auger
Saturday, December 15, 2007 11:36:22 PM UTC
Great video Scott. It's nice to see Microsoft moving in this direction as well as it's good to have you, ScottGu, Rob and Phil to blog about it all. That, perhaps it's ScottGu's best move of all.
Wednesday, December 19, 2007 6:48:08 PM UTC
Why can't I "random access' any location on the video? I stopped watching mid way, and today I wanted to contrinue, but when I started playback, it starts from the start and I cannot skip to the place I left last time.

I run WMP 11, XP.
hernan
Friday, December 21, 2007 1:29:54 AM UTC
Just an update folks, the video is available now in seven different formats as well as just audio at http://www.asp.net/Downloads/3.5-extensions/
Thursday, December 27, 2007 12:31:41 AM UTC
Why did I see a lot of <% %>? Can I bind viewdata to control in design or code behide?
Mac
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.