Hanalei, Hawaii Tuesday, February 09, 2010

MVC Storefront, Part 11: Hooking Up The Shopping Cart And Components

In this episode I hook the site up to the shopping cart and run some tests on my Controllers. I also build a Component with a little-known feature of MVC, the System.

In this episode I hook the site up to the shopping cart and run some tests on my Controllers. I also build a Component with a little-known feature of MVC, the System.Web.MVC.ComponentController.

Code Bath
This screencast is almost pure coding, and in some ways is the weakest one aside from the ComponentController stuff at the end. I felt it was important to show how I had to hook routing up to get the cart bits to work properly, but one thing I left out was the controller testing and mocking I did with Phil, which is coming up in the next screencast.

Errata
I've stopped adding the "Previously, On The MVC Storefront" section because it's getting too long. I've added the links to the side of my blog here.

 

Watch It Here

The Code Is Here.

Technorati Tags:


Ridge - May 24, 2008 -

I want my super-wamadine!

JB - May 24, 2008 -

What's the plan for components - will there be a ComponentActionResult type? will component views be ascx not aspx?

What is this about a 'sub controller'? I keep hearing the phrase but I don't know what that means.

Esico - May 24, 2008 -

well, in this scenario I would probably use a plain usercontrol and control it with public properties. However, I can imagine that you would use that component controller in a single component scenario (like a gridview).

Many thanks for all the movies!

Cheers

Ps

I think you made a copy and paste mistake in your html. You copy and past the outer div elements too which controls the position in your master. You prob did't wanted to do that. Just a design thing.

Jamie - May 24, 2008 -

Will there be any easy way of packaging up components into their own assembly for re-use in other applications? I've played around with compiling regular view pages as resources inside an assembly with their controllers then registering a custom VirtualPathProvider to find those views, and though it worked it all seemed rather cumbersome. It'd be nice if that scenario was more baked in. I can see where certain components might be used in a number of applications and it would be nice to not have to just copy and paste into the component directory every time.

Miha Valencic - June 1, 2008 -

Rob,

with regards to what Jamie says, is there any documentation on "Compoenents" part of the MVC? The documentation on www.asp.net does not seem to mention it.

Also, with regards to components, Authentication/Authorization seem like a good candidates for that. Thinking about it makes me think how it all relates to django middleware. Is there a part of the MVC that relates to functionality like django's middleware "applications"?

Thanks,

Miha.

Gecko