Hi all. I have a need for using Html.RenderUserControl() inside my controller. Specifically, I am doing some AJAX calls whose response is small enough (such as a single form field) to not warrant a full RenderView(). Instead, I am doing HttpContext.Response.Write().
My problem is that I find myself duplicating some view code, in particular my custom controls. These controls do not have any runat=servers in them, they're just a small collection of <%= %> to work on the data. But since I don't have access to Html.RenderUserControl() from my controller actions, I'm having to duplicate the work.
And, as well all know, duplicating work means the code lives in more than one place, which means it needs to be updated in more than one place if ever changed, which means it has bugs in more than one place if it has bugs, etc. Not very DRY.
Since AJAX calls so frequently work with *parts* of pages, it is not uncommon to return only part of a page. Many of my views use custom controls to render them as "partials" to increase their reusability, and I would love to be able to use these controls from the controller for these small AJAX renderings.
Anyway, does anyone have any suggestion about rendering my customer .ASCX controls from inside a controller?