I use this technique to embed MVC partials into webforms pages. Not sure if it works in a webforms user control, but it should be possible.
Step 1. Within the MVC part of your application, create the following helper function. This does all the hard work:
namespace MvcApplication
{
// create a dummy controller
public class DummyController : Controller
{
}
public static class MvcPartialHelper
{
public static void RenderPartial(string partialViewName, object model)
{
ControllerContext controllerContext;
HttpContextBase httpContextBase;
IView view;
RouteData routeData;
ViewContext viewContext;
httpContextBase = new HttpContextWrapper(HttpContext.Current);
routeData = new RouteData();
routeData.Values.Add("controller", typeof(DummyController).Name);
controllerContext = new ControllerContext(new RequestContext(httpContextBase, routeData), new DummyController());
view = ViewEngines.Engines.FindPartialView(controllerContext, partialViewName).View;
viewContext = new ViewContext(controllerContext, view, new ViewDataDictionary { Model = model }, new TempDataDictionary(), httpContextBase.Response.Output);
view.Render(viewContext, httpContextBase.Response.Output);
}
}
}
then, within your web page (or user control):
add the following to reference the above:
<%@ Import Namespace="MvcApplication" %>
and then when you need to display the partial you can add something like:
<% MvcPartialHelper.RenderPartial("~/views/shared/TestPartial.ascx", "hello - this is my model"); %>
where the second parameter is your 'Model'.
I use this technique extensively in a mixed MVC/Webforms environment and it works like a dream!
Enjoy