I'm not talking about hosting ASP.NET with the 'ApplicationHost' class. For example, if I create a Console application, create a valid HttpContext object and pass it to the ProcessRequest of a custom Page object, will it fill the HttpReponse html like if it was running inside ASP.NET?
views:
64answers:
2
A:
If you're talking custom ASP.NET controls, then you can programmatically create them and get them to render to a string easily enough. If that's something you're interested in doing, then I've done it in the past and can dig the code out for you.
Antony Scott
2010-07-01 21:50:56
I'm talking about any kind of class that implements an IHttpHandler.
Thiado de Arruda
2010-07-02 01:10:39
+1
A:
I don't see why not.
Try the RenderControl() method to get the html from a page or Web control.
static public string GetHTML(Control myControl)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter myWriter = new HtmlTextWriter(sw);
myControl.RenderControl(myWriter);
return sw.ToString();
}
I use this to render GridViews asynchronously.
Biff MaGriff
2010-07-02 21:53:53
I was concerned that rendering the html would have dependencies on the Asp.Net runtime on the current appdomain
Thiado de Arruda
2010-07-05 11:21:39