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


C# HttpResponseBase.ClearHeaders方法代码示例

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


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

示例1: FileDownload

 public void FileDownload(HttpResponseBase response,string filePah)
 {
     if(!IsExists(filePah)) {
         throw new Exception("�ļ�������");
     }
     var fileInfo = new FileInfo(filePah);
     response.Clear();
     response.ClearContent();
     response.ClearHeaders();
     response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileInfo.Name,System.Text.Encoding.UTF8));
     response.AddHeader("Content-Length", fileInfo.Length.ToString());
     //response.AddHeader("Content-Transfer-Encoding", "binary");
     response.ContentType = "application/vnd.ms-excel;charset=UTF-8";
     response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
     response.WriteFile(fileInfo.FullName);
     response.Flush();
     response.End();
 }
开发者ID:gowhy,项目名称:LoveBank,代码行数:18,代码来源:FileUploadService.cs

示例2: WriteToHttpResponse

 /// <summary>
 /// Exports the chart to the specified HttpResponse object. This method
 /// is preferred over WriteToStream() because it handles clearing the
 /// output stream and setting the HTTP reponse headers.
 /// </summary>
 /// <param name="httpResponse"></param>
 public void WriteToHttpResponse(HttpResponseBase httpResponse)
 {
     httpResponse.ClearContent();
     httpResponse.ClearHeaders();
     httpResponse.ContentType = this.ContentType;
     httpResponse.AddHeader("Content-Disposition", this.ContentDisposition);
     WriteToStream(httpResponse.OutputStream);
 }
开发者ID:charreal,项目名称:Highcharts-export-module-asp.net-MVC,代码行数:14,代码来源:Exporter.cs

示例3: WriteFile

        protected override void WriteFile(HttpResponseBase response)
        {
            response.BufferOutput = false;

            response.Clear();
            response.ClearContent();
            response.ClearHeaders();
            response.Cookies.Clear();
            response.ContentType = ContentType;
            response.ContentEncoding = Encoding.Default;
            response.AddHeader("Content-Type", ContentType);
            response.AddHeader("Content-Disposition",
                                    String.Format("attachment; filename={0}",
                                    this.FileDownloadName));
            byte[] buffer = new byte[4096];

            using (ZipOutputStream zipOutputStream =
                        new ZipOutputStream(response.OutputStream))
            {
                foreach (string fileName in FilesToZip)
                {
                    int folderOffset = fileName.LastIndexOf('\\');

                    Stream fs = System.IO.File.OpenRead(fileName);    // or any suitable inputstream
                    string entryName = fileName.Substring(folderOffset);
                    ZipEntry entry = new ZipEntry(ZipEntry.CleanName(entryName));
                    entry.Size = fs.Length;
                    // Setting the Size provides WinXP built-in extractor compatibility,
                    //  but if not available, you can set zipOutputStream.UseZip64 = UseZip64.Off instead.

                    zipOutputStream.PutNextEntry(entry);
                    //zipOutputStream.SetLevel(3); // 0-9 for compression level
                    //zipOutputStream.Password(); // security

                    int count = fs.Read(buffer, 0, buffer.Length);
                    while (count > 0)
                    {
                        zipOutputStream.Write(buffer, 0, count);
                        count = fs.Read(buffer, 0, buffer.Length);
                        if (!response.IsClientConnected)
                        {
                            break;
                        }
                        response.Flush();
                    }
                    fs.Close();
                }
                zipOutputStream.Finish();
            }
            //response.OutputStream.Flush();
            response.End();

        }
开发者ID:hanoitown,项目名称:vnsf,代码行数:53,代码来源:DocumentController.cs


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