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


C# HttpResponseBase.TransmitFile方法代码示例

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


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

示例1: WriteEntireEntity

 protected override void WriteEntireEntity(HttpResponseBase response)
 {
     try
     {
         response.TransmitFile(FileName);
     }
     // ReSharper disable EmptyGeneralCatchClause
     catch
     // ReSharper restore EmptyGeneralCatchClause
     {
     }
 }
开发者ID:MulderFox,项目名称:Main,代码行数:12,代码来源:RangeFilePathResult.cs

示例2: WriteEntityRange

        protected override void WriteEntityRange(HttpResponseBase response, long rangeStartIndex, long rangeEndIndex)
        {
            int length = Convert.ToInt32(rangeEndIndex - rangeStartIndex) + 1;

            try
            {
                response.TransmitFile(FileName, rangeStartIndex, length);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
            }
        }
开发者ID:MulderFox,项目名称:Main,代码行数:14,代码来源:RangeFilePathResult.cs

示例3: SendContent

 public virtual bool SendContent(string url, HttpResponseBase response)
 {
     var file = GetFileNameFromConfig(url);
     try
     {
         response.TransmitFile(file);
         RRTracer.Trace("{0} transmitted from disk.", url);
         return true;
     }
     catch (FileNotFoundException)
     {
         try
         {
             response.TransmitFile(file.Insert(file.LastIndexOf('-'), "-Expired"));
             RRTracer.Trace("{0} was expired and transmitted from disk.", url);
             return true;
         }
         catch (FileNotFoundException)
         {
             return false;
         }
     }
 }
开发者ID:HKochniss,项目名称:RequestReduce,代码行数:23,代码来源:LocalDiskStore.cs

示例4: Serve

 public void Serve(HttpResponseBase response, long offset, long length)
 {
     response.TransmitFile(FileName, offset, length);
 }
开发者ID:bmbsqd,项目名称:dynamic-media,代码行数:4,代码来源:TransmitFileResult.cs

示例5: TryTransmitIfContains

 private bool TryTransmitIfContains(string id, HttpResponseBase response) {
     if (EnableAutoPurge) {
         QueueAutoPurge();
     }
     string path = BuildFilePath(id);
     lock (GetFileLockObject(id)) {
         if (File.Exists(path)) {
             response.TransmitFile(path);
             return true;
         }
         else {
             return false;
         }
     }
 }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:15,代码来源:DiskImageStore.cs

示例6: TransmitFile

        /// <summary>
        /// Writes file to response, adds correct headers based on Request headers and file attributes
        /// </summary>
        /// <param name="response"></param>
        protected virtual void TransmitFile(HttpResponseBase response)
        {
            var contentLength = ContentLength();
            response.StatusCode = SendRange() ? (int)HttpStatusCode.PartialContent : (int)HttpStatusCode.OK;

            response.AppendHeader(HttpHeaders.ContentLength, contentLength.ToString(CultureInfo.InvariantCulture));
            response.AppendHeader(HttpHeaders.AcceptRanges, "bytes");
            response.AppendHeader(HttpHeaders.ContentRange, string.Format("bytes {0}-{1}/{2}", _range.Start, _range.End, _file.Length));

            if(!string.IsNullOrWhiteSpace(_downloadFileName))
            {
                response.AddHeader("Content-Disposition", string.Format("attachment;filename=\"{0}\"", _downloadFileName));
            }

            try
            {
                response.TransmitFile(FileName, _range.Start, contentLength);
            }
            catch (Exception ex)
            {
                if(LogException != null)
                {
                    LogException(ex);
                }
            }
        }
开发者ID:eugene-kartsev,项目名称:mvc.stream,代码行数:30,代码来源:ResumeFileResult.cs

示例7: WriteFile

 protected override void WriteFile(HttpResponseBase response) {
     response.TransmitFile(FileName);
 }
开发者ID:nhatquya,项目名称:Samples,代码行数:3,代码来源:FilePathResult.cs

示例8: TryTransmitIfContains

		private bool TryTransmitIfContains (string id, HttpResponseBase response, string imgFile)
		{
			var tmpFiles = Directory.GetFiles (CachePath, id + "_*" + tmpFileExtension);

			// check if we have cache files
			if (tmpFiles.Length > 0)
			{
				// TODO: Log warning about duplicate cache entries

				// we expect to find just one file for each ID
				var tmpFile = tmpFiles [0];

				lock (GetFileLockObject(tmpFile))
				{
					// get tmp short filename without extension
					var tmpFileName = Path.GetFileNameWithoutExtension (Path.GetFileName (tmpFile));
					// extract expire time

					var expireTime = DateTime.MinValue;
					var timeIndex = tmpFileName.LastIndexOf ("_") + 1;

					if (timeIndex > 0)
						expireTime = DateTime.FromFileTime (
							Convert.ToInt64(tmpFileName.Substring (timeIndex)));

					var hitCache = false;

					if (imgFile == "")
					{
						// check if cache is expired
						hitCache = expireTime >= DateTime.Now;
					}
					else if (timeIndex == 0)
					{
						// use original file last write time
						var imgFileInfo = new FileInfo (imgFile);
						var tmpFileInfo = new FileInfo (tmpFile);

						hitCache = tmpFileInfo.LastWriteTime > imgFileInfo.LastWriteTime;
					}

					if (hitCache)
					{
						response.TransmitFile (tmpFile);
						return true;
					}
					else
					{
						File.Delete (tmpFile);
						return false;
					}
				}
			}
			return false;
		}
开发者ID:roman-yagodin,项目名称:R7.ImageHandler,代码行数:55,代码来源:DiskImageStore.cs


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