当前位置: 首页>>代码示例>>C#>>正文


C# HttpResponse.AppendHeader方法代码示例

本文整理汇总了C#中System.Web.HttpResponse.AppendHeader方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.AppendHeader方法的具体用法?C# HttpResponse.AppendHeader怎么用?C# HttpResponse.AppendHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.AppendHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

        public void Process(HttpResponse response)
        {
            response.AppendHeader("Last-Modified", serverFingerprint.LastModifiedTime.ToString("r"));
            response.AppendHeader("ETag", serverFingerprint.ETag);
            response.AppendHeader("Cache-Control", "private, max-age=0");
            if (!string.IsNullOrEmpty(fileName))
            {
                response.AppendHeader(
                    "Content-Disposition",
                    "attachment; filename=\"" + Path.GetFileName(fileName) + "\"");
            }
            if (!string.IsNullOrEmpty(type))
            {
                response.ContentType = type;
            }
            else if (!string.IsNullOrEmpty(fileName))
            {
                var mimeType = GetMimeType(fileName);
                response.ContentType = mimeType;
            }
            else
            {
                response.ContentType = "application/octetstream";
            }

            fileTransfer.Download(response.OutputStream);
        }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:27,代码来源:FileTransferResponse.cs

示例2: AddCompressionFilter

        public static void AddCompressionFilter(HttpRequest request, HttpResponse response)
        {
            // load encodings from header
            QValueList encodings = new QValueList(request.Headers["Accept-Encoding"]);

            // get the types we can handle, can be accepted and
            // in the defined client preference
            QValue preferred = encodings.FindPreferred("gzip", "deflate", "identity");

            // if none of the preferred values were found, but the
            // client can accept wildcard encodings, we'll default
            // to Gzip.
            if (preferred.IsEmpty && encodings.AcceptWildcard && encodings.Find("gzip").IsEmpty)
                preferred = new QValue("gzip");

            // handle the preferred encoding
            switch (preferred.Name)
            {
                case "gzip":
                    response.AppendHeader("Content-Encoding", "gzip");
                    response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
                    break;
                case "deflate":
                    response.AppendHeader("Content-Encoding", "deflate");
                    response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
                    break;
                case "identity":
                default:
                    break;
            }
        }
开发者ID:Santas,项目名称:NodeAssets,代码行数:31,代码来源:EncodingHelper.cs

示例3: Process

 public void Process(HttpResponse response)
 {
     response.AppendHeader("Last-Modified", serverFingerprint.LastModifiedTime.ToString("r"));
     response.AppendHeader("ETag", serverFingerprint.ETag);
     response.AppendHeader("Cache-Control", "private, max-age=0");
     response.BinaryWrite(content);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:7,代码来源:BinaryResponse.cs

示例4: Process

 public void Process(HttpResponse response)
 {
     response.AppendHeader("Last-Modified", serverFingerprint.LastModifiedTime.ToString("r"));
     response.AppendHeader("ETag", serverFingerprint.ETag);
     response.AppendHeader("Cache-Control", "private, max-age=0");
     response.ContentType = MimeType.Json.ContentType;
     response.Write(jsonFragment);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:8,代码来源:JsonFragmentResponse.cs

示例5: ToExcel

        public static void ToExcel(DataSet dsInput, string filename, HttpResponse response)
        {
            var excelXml = GetExcelXml(dsInput, filename);
            response.Clear();
            response.AppendHeader("Content-Type", "application/vnd.ms-excel");
            response.AppendHeader("Content-Disposition", "attachment; filename=\"" + HttpContext.Current.Server.UrlEncode(filename) + "\"");

            response.Write(excelXml);
            response.Flush();
            response.End();
        }
开发者ID:mccj,项目名称:FOMS,代码行数:11,代码来源:ExcelHelper.cs

示例6: ProcessRequest

        /// <summary>
        /// ����IHttpHandler����
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            Request = context.Request;
            Response = context.Response;
            Session = context.Session;

            VerifyImage dt_verifyImage = new VerifyImage();
            dt_verifyImage._Random = new Random();
            dt_verifyImage._Code = dt_verifyImage.GetRandomCode();
            dt_verifyImage.BackColor = ColorTranslator.FromHtml("#edf8fe");
            Session["SystemCode"] = dt_verifyImage._Code;

            ///����û�л���
            Response.Buffer = true;
            Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
            Response.Expires = 0;
            Response.CacheControl = "no-cache";
            Response.AppendHeader("Pragma", "No-Cache");

            Bitmap objBitmap = dt_verifyImage.GetVerifyImage();
            objBitmap.Save(Response.OutputStream, ImageFormat.Gif);
            if (null != objBitmap)
                objBitmap.Dispose();
            Response.ContentType = "image/gif";
            Response.Write(Response.OutputStream);
        }
开发者ID:NickQi,项目名称:TianheDemo,代码行数:30,代码来源:VerifyImageHandler.cs

示例7: AddHeadersToEnable403Cacheing

		private void AddHeadersToEnable403Cacheing(HttpResponse response)
		{
            var browser = HttpContext.Current.Request.Browser;
            if (browser.IsBrowser("IE") && (browser.MajorVersion <= 6))
            {
                // Turn off caching due to issues with IE 6.0
                response.Cache.SetCacheability(HttpCacheability.NoCache);
                response.Cache.SetNoStore();
            }
            else
            {
                response.AppendHeader("Last-Modified", serverFingerprint.LastModifiedTime.ToString("r"));
                response.AppendHeader("ETag", serverFingerprint.ETag);
                response.AppendHeader("Cache-Control", "no-store");
            }
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:16,代码来源:HtmlFragmentResponse.cs

示例8: MakePageExpired

 //public static void DisableMasterPageStamp(Page page)
 //{
 //    Validate.NotNull(page, "page");
 //    if (page.Master != null)
 //    {
 //        Control ctrl = page.Master.FindControl(DoubleSubmitStamp.MasterPageControlName);
 //        if (ctrl != null)
 //            ((DoubleSubmitStamp) ctrl).RenderStamp = false;
 //    }
 //}
 public static void MakePageExpired(HttpResponse response)
 {
     Validate.NotNull(response, "response");
     response.Expires = 0;
     response.Cache.SetNoStore();
     response.AppendHeader("Pragma", "no-cache");
 }
开发者ID:andreyu,项目名称:Reports,代码行数:17,代码来源:WebUtils.cs

示例9: GZipEncodePage

        public static void GZipEncodePage(HttpRequest Request, HttpResponse Response)
        {
            if (!IsGZipSupported(Request)) return;
            string AcceptEncoding = Request.Headers["Accept-Encoding"];

            if (AcceptEncoding.Contains("gzip"))
            {
                Response.Filter = new System.IO.Compression.GZipStream(Response.Filter, System.IO.Compression.CompressionMode.Compress);
                Response.AppendHeader("Content-Encoding", "gzip");
            }
            else
            {
                Response.Filter = new System.IO.Compression.DeflateStream(Response.Filter, System.IO.Compression.CompressionMode.Compress);
                Response.AppendHeader("Content-Encoding", "deflate");
            }
        }
开发者ID:inspira,项目名称:Web.Generics,代码行数:16,代码来源:Gzip.cs

示例10: SetResponseHeader

 private static void SetResponseHeader(HttpResponse response, string buildVersion)
 {
     if (WebVersionConfiguration.Settings.SendResponseHeader)
     {
         response.AppendHeader("X-Web-Version", buildVersion);
     }
 }
开发者ID:kevinobee,项目名称:Web.Version,代码行数:7,代码来源:VersionSummary.cs

示例11: MapResponseToHttpResponse

 private static void MapResponseToHttpResponse(Response response, HttpResponse httpResponse)
 {
     response.Headers.ForEach(header => httpResponse.AppendHeader(header.Key, header.Value));
     httpResponse.StatusCode = response.StatusCode;
     httpResponse.ContentType = response.ContentType;
     response.Contents.Invoke(httpResponse.OutputStream);
 }
开发者ID:jmptrader,项目名称:jessica,代码行数:7,代码来源:JessicaHttpHandler.cs

示例12: EncodeStreamAndAppendResponseHeaders

		public static void EncodeStreamAndAppendResponseHeaders(HttpResponse response, string acceptEncoding)
		{
			if (acceptEncoding == null) return;

			var preferredEncoding = ParsePreferredEncoding(acceptEncoding);
			if (preferredEncoding == null) return;

			response.AppendHeader("Content-Encoding", preferredEncoding);
			response.AppendHeader("Vary", "Accept-Encoding");
			if (preferredEncoding == "deflate")
			{
				response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress, true);
			}
			if (preferredEncoding == "gzip")
			{
				response.Filter = new GZipStream(response.Filter, CompressionMode.Compress, true);
			}
		}
开发者ID:BiYiTuan,项目名称:dotnet,代码行数:18,代码来源:Compression.cs

示例13: SendToResponse

 /// <summary>
 /// Sends the file to the response with content-length header
 /// Works with all types of files, not image specific
 /// </summary>
 /// <param name="response"></param>
 /// <param name="file"></param>
 /// <param name="mimetype"></param>
 private static void SendToResponse(HttpResponse response, byte[] fileContent, DateTime lastWriteTime, string mimetype)
 {
   response.ClearHeaders();
   setCacheHeaders(response);
   
   response.Cache.SetLastModified(lastWriteTime); // to avoid rounding problems with header (no millisecs there)
   response.ContentType = mimetype;      
   response.AppendHeader("Content-Length", fileContent.Length.ToString());
   response.BinaryWrite(fileContent);
   response.End();
 }
开发者ID:BaoToan94,项目名称:q42.wheels.gimmage,代码行数:18,代码来源:HttpImageServer.cs

示例14: Export

	    public virtual void Export(ContentItem item, ExportOptions options, HttpResponse response)
		{
			response.ContentType = GetContentType();
			response.AppendHeader("Content-Disposition", "attachment;filename=" + GetExportFilename(item));

			using (var output = GetTextWriter(response))
			{
				Export(item, options, output);
				output.Flush();
			}
			response.End();
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:12,代码来源:Exporter.cs

示例15: Render

		public void Render(HttpResponse response)
		{
			string serializedItems = ToString();

			response.Clear();
			var calendarName = _calendarName.Replace(',', ' ');
			response.AppendHeader("Content-Disposition",
			                      String.Format("attachment; filename={0}.ics",
			                                    HttpUtility.UrlPathEncode(calendarName)));
			response.ContentType = "text/calendar";

			response.Write(serializedItems);
		}
开发者ID:agross,项目名称:graffiti-usergroups,代码行数:13,代码来源:Calendar.cs


注:本文中的System.Web.HttpResponse.AppendHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。