Scott Hanselman

ASP.NET MVC Beta released - Coolness Ensues

October 17, 2008 Comment on this post [9] Posted in ASP.NET | ASP.NET Dynamic Data | ASP.NET MVC
Sponsored By

ASP.NET MVC is now officially in Beta. Go get it! ScottGu has all the juicy details in his usually Epic style. In a nutshell, this is called Beta (and not Preview 1138) because the quality and the amount of testing gone into it was higher than the Previews and source drops you may have gotten off of CodePlex. It's API surface is pretty stable now.

Also, we're shipping jQuery with ASP.NET MVC! When you go File | New ASP.NET MVC Project, you've already got jQuery. Bam.

Here's what's new in ASP.NET MVC Beta:

If you've been playing it safe as all the Alpha Geeks have been living on the edge, if you're wondering when would be the time to start using ASP.NET MVC or when you could go live, this is a good time to start. This release as a very clear Go-Live license. Totally, (if you haven't already) go out there and put your sites out in public on ASP.NET MVC if you like. It's pretty much feature complete (again, hence, "Beta") and shouldn't change in any major ways between now and it's release in a coming month ending in "-ber" like January-ber or Next June-ber. (Seriously, I have no idea when it'll be out. When it's done. But, we're closer than we were yesterday. Go ask Phil.)

One of the new additions is Model Binders that formalize the relationship between what's happening in HTTP and what ends up happening in your Controller actions. Similar to what you can do in MonoRail with IParameterBinder, you can now do in ASP.NET MVC. For example, back in June I showed how to handle uploaded files with ASP.NET MVC. It was useful, but hard to test and kind of hard to read.

Here's a cleaner way as an example from Levi Broderick, a Developer on the ASP.NET MVC team.

A Sample ModelBinder for HttpPostedFileBase:

public class HttpPostedFileBaseModelBinder : IModelBinder {

public ModelBinderResult BindModel(ModelBindingContext bindingContext) {
HttpPostedFileBase theFile = bindingContext.HttpContext.Request.Files[bindingContext.ModelName];
return new ModelBinderResult(theFile);
}
}

You'd activate it in your global.asax.cs (or .vb):

ModelBinders.Binders[typeof(HttpPostedFileBase)] = new HttpPostedFileBaseModelBinder();

Then you'd make sure the form in your view uses the correct enctype:

<form enctype="multipart/form-data" method="post" action="{some url}">
Choose file: <input name="theFile" type="file">
<input value="Submit Query" type="submit">
</form>

…and finally, in the action method of your controller:

public ActionResult Upload(HttpPostedFileBase theFile) {

// 'theFile' now contains the uploaded file
}

That's it. There's lots of cool binding stuff you can do, but that's just one example.

One other thing I wanted to say. I was in Las Vegas yesterday keynoting VSLive and I made it a point to show this new slide. It's simple, and perhaps obvious, but perhaps not:

I wanted to make it clear that even though folks (and me) might use the term "hybrid" to refer to ASP.NET applications that mix WebForms, MVC and Dynamic Data, that these are all just ASP.NET. Arguably ASP.NET Ajax and the Ajax Controls could be either another circle or part of the larger one.

I also showed ASP.NET+Dynamic Data that you'll be hearing more about at PDC and even more next year. You should feel free to use these subsystems as you like, mix and match, promote and ignore. Whatever makes you happy. All the ASP.NET core stuff like Authentication, Authorization, Session, Caching, etc, that all works in all of these subsystems because they are all ASP.NET.

Wow, that kind of sounded like a political speech! "Can't we all just get along? MVC and WebForms living together, with Dynamic Data by their side..."

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
Hosting By
Hosted in an Azure App Service
October 17, 2008 3:06
Great news... just as my posts on writing a RESTful web service using MVC was getting to usng different verbs you fix the issue I had just stumbled on... two methods with the same name only distinguished by the AcceptVerbs attribute throws an exception. So rather than work round it in Preview 5, I can just download the beta :-)

Only downside is going back over those previous posts to make the code compile with the Beta :-(
October 17, 2008 4:28
Nice Job.
October 17, 2008 6:08
Absolutely great news!
I've been designing and prototyping a new (pretty large) application lately with MVC and was wondering what the status may end up being when we actually release.

Guess the Beta is now somewhat feature-stabilized?

greetings Daniel
October 17, 2008 6:28
Scotty ,
I have already designed a solution around preview 5 and this is a gr8 news. fly high scott
October 17, 2008 17:25
Fantastic,

I love the MVC, I always thought the postback cycle was kludgy. It's been great to watch this Framework progress through CTP.

October 17, 2008 18:34
Keep pushing that message Scott :)

Seriously, I gave a talk a year ago on Monorail, and one of the keys was to note that Monorail sits on the asp.net 'pipeline', and after that I was clear to always say "asp.net webforms" and "asp.net monorail" - for me personally, I see the Webforms as a ViewEngine (I know it's more than that really). The more I studied the underlying asp.net engine, the more I appreciated it's design. It allows for a page controller or front controller approach - which is brilliant, as well as it's clean separation from the core 'http' stuff from the framework that sits on top of it (HttpContext, HttpRequest/HttpResponse)

So, with asp.net mvc, it's important to realize that it sits on top of the same underlying asp.net engine as webforms.

I'm glad to see the 'hybrid' approach - this will allow me, someone who has quickly adopted to mvc to have some options if I'm working in a webform environment.

Thanks again - and keep spreading the message!
October 23, 2008 13:04
Similar to what you can do in MonoRail with IParameterBinder, you can now do in ASP.NET MVC
Yeah, ASP.NET MVC is almost as cool as MonoRail ;)

The more I studied the underlying asp.net engine, the more I appreciated it's design.
ASP.NET is truly a work of art, with great design and endless extension points. I think that MonoRail and ASP.NET MVC both serve as a proof for that.


Though Im super comfy with MonoRail (having lots of experience with it, and being a committer for Castle) I am also liking ASP.NET MVC a lot, for the way it adhere to the same ideas - of simplicity and extensibility.

November 14, 2008 16:51
Scott,
What fo you think, is ASP.NET MVC ready for production usage or it would be better to wait release?
November 14, 2008 21:33
Fedorov - I think that I'd go live with what we have, but if you're not comfortable, you should totally start coding your project now with the Beta.

Comments are closed.

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