internal void ProcessRequestInternal(HttpContext context)
        {
            // enable dynamic validation for this request
            ValidationUtility.EnableDynamicValidation(context);
            context.Request.ValidateInput();

            try {
                HttpContextBase contextBase = new HttpContextWrapper(context);
                //WebSecurity.Context = contextBase;
                AddVersionHeader(contextBase);

                WebPageRenderingBase startPage = StartPage.GetStartPage(_webPage, StartPageFileName, WebPageHttpHandler.GetRegisteredExtensions());

                // This is also the point where a Plan9 request truly begins execution

                // We call ExecutePageHierarchy on the requested page, passing in the possible initPage, so that
                // the requested page can take care of the necessary push/pop context and trigger the call to
                // the initPage.
                _webPage.ExecutePageHierarchy(Util.CreatePageContext(context), context.Response.Output, startPage);

                if (ShouldGenerateSourceHeader(contextBase))
                {
                    GenerateSourceFilesHeader(_webPage.PageContext);
                }
            }
            catch (Exception e) {
                if (!HandleError(e))
                {
                    throw;
                }
            }
        }
    public static string ParseRazor(string virtualPath, object model)
    {
        string pageVPath = virtualPath;

        try
        {
            Type t = BuildManager.GetCompiledType(pageVPath);
            if (t != null)
            {
                HttpContextWrapper wrapper = new HttpContextWrapper(HttpContext.Current);

                object inst = Activator.CreateInstance(t);

                System.Web.WebPages.WebPage webpage = inst as System.Web.WebPages.WebPage;
                webpage.VirtualPath = pageVPath;
                StringWriter writer = new StringWriter();
                webpage.ExecutePageHierarchy(new System.Web.WebPages.WebPageContext(wrapper, webpage, model), writer, webpage);
                string content = writer.ToString();

                return(content);
            }
        }
        catch (Exception ex)
        {
            Utils.Log(string.Format("RazorHelper, ParseRazor, VirtualPath: {0}", virtualPath), ex);

            // return the error message since it will usually contain parsing
            // details when the Razor markup/syntax is invalid.  this will help
            // when debugging, so the error log does not need to be checked.
            return(ex.Message);
        }

        return(null);
    }
        internal void ProcessRequestInternal(HttpContextBase httpContext)
        {
            try
            {
                //WebSecurity.Context = contextBase;
                AddVersionHeader(httpContext);

                // This is also the point where a Plan9 request truly begins execution

                // We call ExecutePageHierarchy on the requested page, passing in the possible initPage, so that
                // the requested page can take care of the necessary push/pop context and trigger the call to
                // the initPage.
                _webPage.ExecutePageHierarchy(new WebPageContext {
                    HttpContext = httpContext
                }, httpContext.Response.Output, StartPage);

                if (ShouldGenerateSourceHeader(httpContext))
                {
                    GenerateSourceFilesHeader(_webPage.PageContext);
                }
            }
            catch (Exception e)
            {
                if (!HandleError(e))
                {
                    throw;
                }
            }
        }