Exemplo n.º 1
0
        /// <summary>
        /// 根据RenderMode输出
        /// </summary>
        /// <param name="baseRenderString"></param>
        /// <param name="renderMode"></param>
        public static void RenderPageOnlySelf(this PageRenderMode renderMode, string baseRenderString)
        {
            HttpResponse response = HttpContext.Current.Response;

            response.ClearContent();
            response.ContentEncoding = Encoding.UTF8;
            response.Charset         = "utf-8";

            string htmlContentType = WebUtility.GetContentTypeByKey(ResponseContentTypeKey.HTML);
            string contentType     = WebUtility.GetContentTypeByKey(renderMode.ContentTypeKey);

            if (contentType == string.Empty)
            {
                contentType = htmlContentType;
            }

            response.ContentType = contentType;

            switch (renderMode.DispositionType)
            {
            case ResponseDispositionType.Inline:
            case ResponseDispositionType.Attachment:
                response.AppendHeader("CONTENT-DISPOSITION",
                                      string.Format("{0};filename={1}", renderMode.DispositionType, response.EncodeFileNameInContentDisposition(renderMode.AttachmentFileName)));
                break;
            }

            response.Write(baseRenderString);
            response.End();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取当前请求的PageRenderMode
        /// </summary>
        /// <returns>PageRenderMode</returns>
        /// <remarks>获取当前请求的PageRenderMode</remarks>
        public static PageRenderMode GetRequestPageRenderMode()
        {
            HttpContext    context  = HttpContext.Current;
            string         cacheKey = PageRenderModeQueryStringName;
            PageRenderMode mode     = (PageRenderMode)context.Items[cacheKey];

            if (mode == null)
            {
                string str = GetRequestParamString(PageRenderModeQueryStringName, string.Empty);
                mode = str == string.Empty ? new PageRenderMode() : new PageRenderMode(str);
                context.Items[cacheKey] = mode;
            }

            return(mode);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 将PageRenderMode添加到当前请求ExecutionUrl,并返回Url
 /// </summary>
 /// <param name="pageRenderMode">PageRenderMode</param>
 /// <param name="ignoreParamNames">忽略原始的QueryString中参数名称</param>
 /// <returns>结果Url</returns>
 /// <remarks>将PageRenderMode添加到当前请求ExecutionUrl,并返回Url</remarks>
 public static string GetRequestExecutionUrl(PageRenderMode pageRenderMode, params string[] ignoreParamNames)
 {
     return(GetRequestExecutionUrl(PageRenderModeQueryStringName, pageRenderMode.ToString(), ignoreParamNames));
 }