Can I display html from ASP.NET page objects outside of ASP.NET applications?

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 the user page object, it will populate the html HttpReponse, as if it were running inside ASP.NET?

+5
source share
2 answers

I don’t understand why not.

Try the RenderControl () method to get html from a web 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.

+3
source

ASP.NET, . , , .

0

All Articles