You can just cut and paste the code into a static class and just use <% Html.Call<ErrorsController>( c => c.Show() ); %> to run your controller actions (be careful, these actions should only render controls, not pages, or you'll end up with whole
pages inside your main page. not good)
You shouldn't need be concerned with how it works (assuming it does work, i haven't extensively tested it). It should come out of the box, but you're right, it doesn't!
Note: Rob Conery has created a new extension method called RenderAction, which does just this, which will be in the next drop of the MVC Toolkit.
tgmdbm
Contributor
4392 Points
883 Posts
ASPInsiders
MVP
Re: Web User Controls + Controllers?
Jan 21, 2008 05:57 AM|LINK
You can just cut and paste the code into a static class and just use <% Html.Call<ErrorsController>( c => c.Show() ); %> to run your controller actions (be careful, these actions should only render controls, not pages, or you'll end up with whole pages inside your main page. not good)
You shouldn't need be concerned with how it works (assuming it does work, i haven't extensively tested it). It should come out of the box, but you're right, it doesn't!
Note: Rob Conery has created a new extension method called RenderAction, which does just this, which will be in the next drop of the MVC Toolkit.
http://blog.wekeroad.com/2008/01/07/aspnet-mvc-using-usercontrols-usefully/