tags:

views:

89

answers:

1

I'm writing a view helper based on the ideas about partial requests from this blog post: http://blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc/

In the controller action I prepare a widget by running:

AddWidget<Someontroller>(x => x.OtherActionName(new List<int>()));

Then in my view I can run the action and render the view output by doing some form of:

Html.RenderWidget...

And here comes my question, what compiler checked syntax would you choose from the following to use in the view:

Html.RenderWidget<SomeController, List<int>>(x => x.OtherActionName);

Html.RenderWidget<SomeController>(x => x.OtherActionName(null));

Html.RenderWidget<SomeController>(x => x.OtherActionName(It.IsAny<List<int>>);

Can anyone name some pros and cons? Or is it better to go with strings as the original Partial Request implementation does?

PS. Don't take the naming of It.IsAny> to litteraly, I just thought it was best described using the Moq naming.

+1  A: 

Using the strings is significantly faster than using so-called strongly typed helpers (really; it's like 10 times faster), unless you implement some kind of caching for your Expression parsing. Note, though, that MVC 2 may have something along these lines RSN. So one option, if you can, is to just wait and see what's in the next preview drop. At the very least, you'll want to look like the rest of MVC, and the MVC team may end up doing your work for you.

("So called" because under the covers they're going to end up as strings in a RouteValueDictionary anyway.)

Craig Stuntz
Thanks. I havn't thought about speed at all, so that's a good one. Caching should be simple to do though.
asgerhallas