コード例 #1
0
        void IActionResult.Ouput(HttpContext context)
        {
            if (string.IsNullOrEmpty(this.VirtualPath))
            {
                this.VirtualPath = context.Request.FilePath;
            }

            context.Response.ContentType = "text/html";
            string html = PageExecutor.Render(context, VirtualPath, Model);

            context.Response.Write(html);
        }
コード例 #2
0
        /// <summary>
        /// 用指定的Page以及视图数据呈现结果(HTML),
        /// 然后将产生的HTML代码写入HttpContext.Current.Response
        /// 用户控件应从MyPageView&lt;T&gt;继承
        /// </summary>
        /// <param name="pageVirtualPath">Page的虚拟路径</param>
        /// <param name="model">视图数据</param>
        /// <param name="flush">是否需要在输出html后调用Response.Flush()</param>
        public static void WritePage(string pageVirtualPath, object model, bool flush)
        {
            HttpContext context = HttpContext.Current;

            if (context == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(pageVirtualPath))
            {
                pageVirtualPath = context.Request.FilePath;
            }

            string html = PageExecutor.Render(context, pageVirtualPath, model);

            WriteHtml(html, flush);
        }