she swears <i>geek</i> is a term of endearment

Asp.Net beta is out and I’m screwed

With each preview release of Asp.Net MVC, I’ve had quite a few issues to resolve.  Most of these were well documented and I was able to resolve them by reading the release notes and the upgrade instructions.  Unfortunately, Beta is a little different.  

Blame it on Apple

I’ve been iPhone bound for a while.  I skipped Preview 5.  I would have caught this issue then and probably avoided the problem that I am currently facing as I believe we wrote most of this code after the Preview 5 drop.  Thanks alot, Apple, for making iPhone development so freakin’ cumbersome!

Rendering Partial Views

One of the features of Asp.Net MVC that I absolutely LOVED was the ability to render a user control to a string and then mess with that html.  Seriously, that capability was incredibly valuable.  Brad Wilson decided to axe it.  He had a Microsoft-typical attitude that he should change the code to restrict the consumer into following his pattern for use rather than leaving it open as it was before.  Yes, Brad, I am angry with you right now…

Listed incorrectly as an added feature…

  • Added support for rendering partial views. You have several options for passing view data to the partial view. The partial view can be rendered by a different view engine than the containing view. Usage is <% Html.RenderPartial(…); %>. This method does not return a string, but instead renders to the TextWriter instance of the underlying response.

Here’s what I had before (yes, I could render partials before):

HtmlContent.AppendLine(
    Html.RenderUserControl( 
        "~/Views/Components/Charts/RatingReturnChart.ascx", 
        this.ViewData.Model, 
        new { Weighted = true, CurrentTimePeriod = requestedTimePeriod }
    )
);

After the html was rendered, it was passed to another control that accepted a string for "other stuff" that it wasn’t responsible for.  There are other ways to solve this problem but this was something that was easy and didn’t violate our desire to keep separate concerns, separate.

Now the damn thing uses the TextWriter attached to the response object.  So much for extensibility and object oriented programming.  Let’s hardwire into the response object, just like webforms.  Nice work, Brad.  Love it.  Great.  Now I have to create a user control and move my page logic into the control because I can’t define my own context and behavior.  Just like webforms.  Hey, are you going to insert view state and post-back on your next big brain storm?  That’ll be swell. 

Back to the drawing board

Where did I put that Rails Recipes book?

3 Responses to “Asp.Net beta is out and I’m screwed”

  1. Glad I could be of service! :)

    In all seriousness, the reason for using a TextWriter is to increase scalability and reduce memory pressure when rendering pages. And it is a new feature, since you can actually mix view engines within your application (and even use different view engines between views and embedded partials).

    For testability purposes, the TextWriter is effectively identical to a string, since you can just pass a StringWriter to the view and then inspect the string when you’re done.

  2. […] page refresh. There were many people asking the same question and lots of people like my friend Rusty Zarse becoming very frustrated, but no-one had an answer that helped us. All the demos I used to learn MVC (MVCNorthwind, MVC […]

  3. @Brad Wilson

    Then I am off to inspect that possibility. Thanks for the response

    @Paul Lockwood

    How’s it going?

    @Brad Wilson

    Sorry for the attitude. Looks like i had a bad day. I love Microsoft, really! I am so happy coding Asp.Net MVC again I can’t even tell you. If I get MVC updated, I’ll post something useful (unlike my rant)

Leave a Reply