The Texas Tour of ASP.NET MVC Comes to a Close

It’s been an exciting two weeks.  I visited user groups in San Antonio, Houston, Austin, and Fort Worth, and I got to meet and connect with a lot of interested developers about the new ASP.NET MVC framework.

Two of the events were recorded, so if I ever get my hands on the recorded bits, I’ll post them here in an easily watchable format.  (Don’t hold your breath though.)

My presentation had a minimal amount of PowerPoint.  I decided to focus on real code.  And people have thanked me for it! 

I covered:

  • Basics of MVC
  • Default Routes
  • Simple Controller / Action
  • Passing data to the views
  • passing strongly typed view data
  • Custom Routes
  • new/edit form for an entity
  • writing tests for controllers
  • rhino mocks for mocking out dependencies
  • dependency injection for controllers (using Windsor)
  • ajax integration with prototype

This is a lot to tackle in my 1/1.5 hour time slot.  And I do get a lot of blank stares when I talk about mock objects and dependency injection, but I think more presentations need to present realistic code, rather than simple examples.  The feedback I’ve gotten about this has been overwhelmingly positive, and I’m really glad people liked it.

Some questions that were asked during my tour…

“Ben, you are phenominally good-looking?  Are you available?”
umm no, I’m married (and now terrified)

What is that cool zoomey tool you used?  That’s awesome!”
that is called ZoomIt, by sysinternals.

What are you using for data access on your entities?”
It’s called Castle ActiveRecord, which uses NHibernate underneath.

Can I use ASP.NET validators?”
—Well not really.  The validators have viewstate, which won’t work.  Your validation definitely belongs in the Model, so you could just do server-side if you want.  If you want clientside validation, you could accomplish a similar result by using marker css classes and some clever javascript  (think <input type=”text” class=”required” name=”address1” /><span class=”error_message”>This is required</span>

If we use this on IIS6, will performance suffer?”
— Probably.  On IIS 5/6 you have to send all requests through ASP.NET, which can be slower.  I’m not an expert in this area, so definitely do your research before making any rash decisions.  When we have Windows Server 2008 and IIS7, expect vast improvements.

Do you know Justice Gray?”
—Sure do.  I’m a bona-fide potential friend of Justice Gray, and even have the certificate to prove it.  It’s serial number marked 00000000000003.  I carry it with me at all times for just such a question.

Can you use co-exist with webforms?”
—Yes!  If you hit a page with the .aspx extension, the PageHandlerFactory will pick it up and you will be in WebForms Land.  If you instead hit a route, you’ll be in MVC Land.  Learn to know the difference and you’ll be fine.

Isn’t it dangerous to output strings directly like that?”
—Yes it is.  Read my post about html encoding your values.

Your hair is impeccable?  What kind of gel do you use?”
— It’s called Fructis something-or-other… and it’s awesome!

So Microsoft has two methods of developing web applications?  Which should I choose?”
—If you like the rich eventing model and the ability to save state and mimick a smart client ui, then choose web forms.  If you value clean html, urls, separation of concerns, and testability, then choose MVC.  I will be choosing MVC more often than not from here on out.

When will it be released”
—Gawsh, I don’t know?  Fall 2008?  As soon as I know I’ll post it here.

(admittedly, a couple of those questions were not asked — I’ll let you guess which ones)

You can download the code and the presentation here:

File Attachment: save the world with asp.net mvc.zip (1612 KB)

I’d like to thank the user group leaders for having me speak, it was certainly a pleasure.  Where will the next tour be?

#1 Bud Panjwani avatar
Bud Panjwani
1.17.2008
4:26 PM

I am one of the members from Alamocoders.net (SA) and I really enjoyed your presentation.It was easy to understand very educational.I hope you do more presentations in San Antonio.Thanks.


#2 Scott Bateman avatar
Scott Bateman
1.18.2008
10:46 PM

Ben, congrats on the successful tour.As well delivered as your presentations are, I am sure people were able to get a lot out of it.Sorry I couldn't make the Houston showing.So I have a question/thought/comment to get the controversy started.Isn't one of the primary benefits of having a "model" (the M in MVC, MVP, etc) in your pattern to provide accessibility of business object to a wide variety of software components such as web pages, services, windows forms, compact framework apps, and toaster ovens?I am very much intrigued by the ASP.NET MVC concept (I hate viewstate), but why did they corner it into a web based manifestation?I deal primarily in WinForms apps, so I am wondering how much time I should invest in learning about Scott Gu's latest brain child.


#3 Ben Scheirman avatar
Ben Scheirman
1.19.2008
1:13 AM

The model isn't tied to the web application, that's just a folder they've created.There's nothing stopping you from consuming entities from another assembly as your model, or to define a custom presentation model that supports your view.Be careful when assuming that your model can be consumed by all of those things.Often times the best solution is to map the domain model into something more easily fit for the intended client.This way if the needs of the application change, they don't affect the clients and vice-versa.The only change needed would be in the mapping layer.


#4 Justice~! avatar
Justice~!
1.19.2008
2:51 PM

I would think it obvious that the questions about IIS6 performance, the tools you used, and ASP.NET in general were not asked.Do I win a prize?


#5 Tyler avatar
Tyler
1.23.2008
3:42 PM

So I have a question in regards to:“Ben, you are phenominally good-looking?Are you available?”Did the person(woman?) actually state that you are good looking in the form of a question? Did the tone of her voice raise at the end of the sentence? What a strange way to approach someone..."I'm Ron Burgundy?"