public PushContext ( System.Web.WebPages.WebPageContext pageContext, |
||
pageContext | System.Web.WebPages.WebPageContext | |
writer | ||
return | void |
public void PushContext(WebPageContext pageContext, TextWriter writer)
{
_currentWriter = writer;
PageContext = pageContext;
pageContext.Page = this;
InitializePage();
// Create a temporary writer
_tempWriter = new StringBlockWriter(CultureInfo.InvariantCulture);
// Render the page into it
OutputStack.Push(_tempWriter);
SectionWritersStack.Push(new Dictionary<string, SectionWriter>(StringComparer.OrdinalIgnoreCase));
// If the body is defined in the ViewData, remove it and store it on the instance
// so that it won't affect rendering of partial pages when they call VerifyRenderedBodyOrSections
if (PageContext.BodyAction != null)
{
_body = PageContext.BodyAction;
PageContext.BodyAction = null;
}
}
public string ExecutCore(string basePath, string virtualPath, WebPageBase page) { var sb = new StringBuilder(); using (var tw = new StringWriter(sb)) { var context = new HttpContextWrapper(CreateContext(basePath, virtualPath, tw)); var pageContext = new WebPageContext(context, page, null); page.PushContext(pageContext, tw); page.Execute(); page.PopContext(); } return sb.ToString(); }