Geeks With Blogs
Zackary Geers blog January 2010 Entries
Rendering MVC Actions on Asp.Net pages
This is just an extension of my earlier post. You can easily render an Action on a standard ASP.Net page with the following code. The SimpleViewDataContainer is the same one from my previous post. HtmlHelper helper = new HtmlHelper(new ViewContext(), new SimpleViewDataContainer()); helper.ViewContext.HttpContext =new HttpContextWrapper(HttpCont... helper.RenderAction<Home... ......

Posted On Thursday, January 14, 2010 1:55 PM

MVC Helpers inside of Old Pages
I'm working on a existing project, where we've recently added in MVC, but there's a lot of existing Asp.Net code. I wanted MVC to generate the link for me instead of hard coding it. Here's how I did it. I started by creating a class that implments IViewDataController, so I can construct the helper I need. Then I can new up the HtmlHelper, set it's Context, and I have access to all of the MVC goodness inside of my old page. public class SimpleViewDataContainer : IViewDataContainer { public SimpleViewDataContainer() ......

Posted On Wednesday, January 13, 2010 9:41 PM

Copyright © Zackary Geers | Powered by: GeeksWithBlogs.net