mhinze.com

Matt Hinze, learning in public

Archive for the ‘ASP.NET MVC’ Category

Jeffrey and Eric will be delivering a free afternoon of ASP.NET MVC in Austin on Tuesday, June 16th.  If you haven’t yet had a run-in with the new framework or if you’re ready to see what we’ve learned using ASP.NET MVC in the field, this afternoon will be an excellent opportunity to compress learning and [...]

SubControllers and ViewModel

SubControllers solved a big problem for us when we first started our current project.  I posted about them back in the day.
The problem was isolating authorization to view sections of a page.  In other words, if you didn’t have permission X, you couldn’t see the top-left section of the screen.  If you didn’t have permission [...]

Passing objects to SubControllers

SubControllers are MVC Controllers that are also parameters to your action methods.  Incorporating their use in large systems allows for composition, dependency inversion, and separation of concerns.
Sometimes we want Controller actions to pass objects into SubControllers so that the SubControllers can do interesting things with them. 
For example, in a Product Controller we have the [...]

SubControllers in ASP.NET MVC

I should have known something was up when I caught Jeffrey Palermo (my boss at Headspring) browsing the ASP.NET MVC Preview 5 source.
We’re working on a enterprise web application using ASP.NET MVC.  That week one of our tasks was to create a rather complex page full of robust components that did intricate little things [...]

Upgraded to Preview 5

ASP.NET MVC Preview 5 dropped a few days ago and I upgraded my apps today.  Just a few minor notes on the process, which was painless. Most changes are covered in the release notes.

RenderUserControl is now RenderPartial
Asserting that Controller.View() was called now looks like:

Assert.That(viewResult.ViewName, Is.EqualTo(string.Empty));

Some HtmlHelper changes.  Some are great but the behavior of the [...]

After reviewing Rob Conery’s post, a few notes:

Syntax (no <%=):

<% Html.RenderAction<PersonComponentController>(c=>c.List()); %>

The component does not share ViewData with the er, “calling view”..
You can use a View User Control (ascx) or a View Page (aspx).
By default the component is browsable. You can turn this off using IgnoreRoute:

routes.IgnoreRoute(“PersonComponent/{action}”);

On the implicit MVC violations, Phil says:

My personal opinion [...]

Eilon was correct – they made it easier!
It’s trivial to test TempData now. This is all that’s needed to port the example from his earlier post to Preview 4 (thanks Ben):
[TestFixture]
public class HomeControllerTests
{
[Test]
public void IndexSavesUserIDToTempDataAndRedirects()
{
var [...]