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.
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.
Similar to what you can do in MonoRail with IParameterBinder, you can now do in ASP.NET MVC
The more I studied the underlying asp.net engine, the more I appreciated it's design.
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.