I am using the following code to render a spark view into Html. This works fine when the page doesn't contain any web form elements. Specifically is fails on #Html.BeginForm in a template file. I also noticed that the view has a null value for the request and response properties, even though the controller I am passing has them in the descriptor.
public static string GetPartialViewHtml(ControllerBase controller, ViewDataDictionary viewData, string viewRalativePath)
{
SparkViewFactory f = (SparkViewFactory)ViewEngines.Engines.First(e => e is SparkViewFactory);
IList<string> l = new List<string>();
SparkViewDescriptor d = f.CreateDescriptor(controller.ControllerContext, "logon", null, false, l);
SparkView view = (SparkView)f.Engine.CreateInstance(d);
view.ViewData = viewData;
StringWriter writer = new StringWriter();
view.RenderView(writer);
return writer.ToString();
}
Is there any way I can get this to work?
Phil