static void ExecutePage(HttpContext context, string virtualPath, PageBase page, Page pageNode, bool silent)
{
Page originalCurrentPage = PortalContext.Current.Page;
string originalPath = context.Request.Path;
if (originalCurrentPage.Path == pageNode.Path)
throw new InvalidOperationException("Executing a Page within itself is forbidden!");
try
{
PortalContext.Current.Page = pageNode;
context.RewritePath(virtualPath);
context.Server.Execute(page, TextWriter.Null, false);
}
catch (Exception e)
{
if (!silent)
throw e;
else
Logger.WriteException(e);
}
finally
{
context.RewritePath(originalPath);
PortalContext.Current.Page = originalCurrentPage;
}
}