I am attempting to render a partial view to a string from within a controller. I am using the following which is working well:

```
    StringBuilder ViewBuilder = new StringBuilder();
    using (StringWriter ViewWriter = new StringWriter(ViewBuilder))
    {
        ViewEngineResult ViewResult = ViewEngines.Engines.FindPartialView(PageController.ControllerContext, controlName);
        ViewContext ViewContext = new ViewContext(PageController.ControllerContext, ViewResult.View, PageController.ViewData, PageController.TempData, ViewWriter);
        ViewResult.View.Render(ViewContext, ViewWriter);
    }
    return ViewBuilder.ToString();

```

Reference: <http://craftycodeblog.com/2010/05/15/asp-net-mvc-render-partial-view-to-string/>

However I would like to be able to load typed model data into this view as well. I am looking for ideas on how this might be done.

Thanks

---

**Edit**:

It turns out I was looking in the wrong spot. I was able to set it using the ViewDataDictionary, see below:

```
ViewDataDictionary ViewData = new ViewDataDictionary();
ViewData.Model = GetModelState();

```