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


C# HttpResponseBase.End方法代码示例

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


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

示例1: GetFile

        public static ActionResult GetFile(HttpResponseBase Response, HttpRequestBase Request, HttpServerUtilityBase Server,
            string filePath, string fileName, string contentType, string userFileName)
        {
            byte[] value;
            using (FileStream stream = System.IO.File.Open(filePath, FileMode.Open))
            {
                value = new byte[stream.Length];
                stream.Read(value, 0, (int)stream.Length);
            }
            //const string userFileName = "MissionOrder.pdf";
            //const string contentType = "application/pdf";
            Response.Clear();
            if (Request.Browser.Browser == "IE")
            {
                string attachment = String.Format("attachment; filename=\"{0}\"", Server.UrlPathEncode(userFileName));
                Response.AddHeader("Content-Disposition", attachment);
            }
            else
                Response.AddHeader("Content-Disposition", "attachment; filename=\"" + userFileName + "\"");

            Response.ContentType = contentType;
            Response.Charset = "utf-8";
            Response.HeaderEncoding = Encoding.UTF8;
            Response.ContentEncoding = Encoding.UTF8;
            Response.BinaryWrite(value);
            Response.End();
            return null;
        }
开发者ID:andreyu,项目名称:Reports,代码行数:28,代码来源:GraphicsController.cs

示例2: Redirect

 private IHttpHandler Redirect(HttpResponseBase response, string url)
 {
     response.AddHeader("Location", url);
     response.StatusCode = 301;
     response.End();
     return null;
 }
开发者ID:revolutionaryarts,项目名称:wewillgather,代码行数:7,代码来源:LegacySitemapHandler.cs

示例3: Deny

 public void Deny(HttpResponseBase response)
 {
     Contract.Requires(response != null);
     response.StatusCode = (int)HttpStatusCode.Forbidden;
     response.StatusDescription = "403 Forbidden";
     response.End();
 }
开发者ID:josemrb,项目名称:RequestFilter,代码行数:7,代码来源:RequestProcessor.cs

示例4: Execute

		public virtual void Execute(HttpResponseBase response)
		{
			response.StatusCode = 200;
			response.ContentType = "text/html";

			var masterControls = new List<IControlPanelControl>();

			masterControls.AddRange(CreateHeaderControls(_securityState));
			
			masterControls.AddRange(_controls);

			masterControls.AddRange(CreateFooterControls());

			using (var writer = new HtmlTextWriter(response.Output))
			{
				// this securitydisabler allows the control panel to execute unfettered when debug compilation is enabled but you are not signed into Sitecore
				using (new SecurityDisabler())
				{
					foreach (var control in masterControls)
						control.Render(writer);
				}
			}

			response.End();
		}
开发者ID:GlennHaworth,项目名称:Unicorn,代码行数:25,代码来源:ControlPanelPageResponse.cs

示例5: Apply

        public static void Apply(this CommandResult commandResult, HttpResponseBase response)
        {
            if (commandResult == null)
            {
                throw new ArgumentNullException(nameof(commandResult));
            }

            if (response == null)
            {
                throw new ArgumentNullException(nameof(response));
            }

            if (commandResult.HttpStatusCode == HttpStatusCode.SeeOther || commandResult.Location != null)
            {
                if (commandResult.Location == null)
                {
                    throw new InvalidOperationException("Missing Location on redirect.");
                }
                if (commandResult.HttpStatusCode != HttpStatusCode.SeeOther)
                {
                    throw new InvalidOperationException("Invalid HttpStatusCode for redirect, but Location is specified");
                }

                response.Redirect(commandResult.Location.OriginalString);
            }
            else
            {
                response.StatusCode = (int)commandResult.HttpStatusCode;
                response.ContentType = commandResult.ContentType;
                response.Write(commandResult.Content);

                response.End();
            }
        }
开发者ID:biancini,项目名称:OpenIDConnect-Csharp-Client,代码行数:34,代码来源:CommandResultHttpExtension.cs

示例6: Execute

		public virtual void Execute(HttpResponseBase response)
		{
			if (_isAutomatedTool)
			{
				var console = new UnicornStringConsole();
				ProcessInternal(console);

				response.ContentType = "text/plain";
				response.Write(_title + "\n\n");
				response.Write(console.Output);

				if (console.HasErrors)
				{
					response.StatusCode = 500;
					response.TrySkipIisCustomErrors = true;
				}

				response.End();
			}
			else
			{
				var console = new CustomStyledHtml5WebConsole(response);
				console.Title = _title;
				console.Render(ProcessInternal);
			}
		}
开发者ID:hbopuri,项目名称:Unicorn,代码行数:26,代码来源:WebConsoleResponse.cs

示例7: WriteFile

        protected override void WriteFile(HttpResponseBase response)
        {
            response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", FileDownloadName));
            byte[] fileContents = Convert.FromBase64String(_base64);

            response.BinaryWrite(fileContents);
            response.End();
        }
开发者ID:travbod57,项目名称:KendoMVCRampUp,代码行数:8,代码来源:ExcelResult.cs

示例8: WriteFile

		protected override void WriteFile(HttpResponseBase response)
		{
			var rssFormatter = new Rss20FeedFormatter(Feed);

			using (var writer = XmlWriter.Create(response.Output))
				rssFormatter.WriteTo(writer);

			response.End();
		}
开发者ID:NovusCraft,项目名称:NovusCraft,代码行数:9,代码来源:RssResult.cs

示例9: HandleException

        public void HandleException(HttpResponseBase response, Exception exception)
        {
            var route = _exceptionRouteProvider.GetRoute(exception);

            if (route != null)
            {
                response.RedirectToRoute(route);
                response.End();
            }
        }
开发者ID:HenryKeen,项目名称:exception-redirection,代码行数:10,代码来源:ExceptionHandler.cs

示例10: WriteToHttpResponse

		public void WriteToHttpResponse(HttpResponseBase httpResponse)
		{
			httpResponse.Clear();
			httpResponse.ContentType = "application/zip";
			httpResponse.AddHeader("Content-Disposition", "attachment;filename=remoting-package.zip");

			WriteToStream(httpResponse.OutputStream);

			httpResponse.End();
		}
开发者ID:GlennHaworth,项目名称:Unicorn,代码行数:10,代码来源:RemotingPackage.cs

示例11: DiplomProjectToWord

 public static void DiplomProjectToWord(string fileName, DiplomProject work, HttpResponseBase response)
 {
     response.Clear();
     response.Charset = "ru-ru";
     response.HeaderEncoding = Encoding.UTF8;
     response.ContentEncoding = Encoding.UTF8;
     response.ContentType = "application/vnd.ms-word";
     response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ".doc");
     CreateDoc(work, response);
     response.Flush();
     response.End();
 }
开发者ID:MikhailGogolushko,项目名称:lmsystem,代码行数:12,代码来源:Word.cs

示例12: Execute

		public virtual void Execute(HttpResponseBase response)
		{
			response.StatusCode = (int)_statusCode;

			if (_statusCode != HttpStatusCode.OK) response.TrySkipIisCustomErrors = true;

			response.ContentType = _contentType;

			_body(response);

			response.End();
		}
开发者ID:hbopuri,项目名称:Unicorn,代码行数:12,代码来源:ApiResponse.cs

示例13: SetHttpResponse

        private void SetHttpResponse(HttpResponseBase httpResponse, string fileNameWithoutExtension, ExcelPackage package)
        {
            httpResponse.ClearContent();
            httpResponse.Buffer = true;

            //Write it back to the client
            httpResponse.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            httpResponse.AddHeader("content-disposition", string.Format("attachment;  filename={0}.xlsx", fileNameWithoutExtension));
            httpResponse.BinaryWrite(package.GetAsByteArray());

            httpResponse.Flush();
            httpResponse.End();
        }
开发者ID:RyhilaEbrahim,项目名称:LendingLibrary,代码行数:13,代码来源:ExcelService.cs

示例14: WriteFile

        protected override void WriteFile(HttpResponseBase response)
        {
            _isRssFeed = _feedType == FeedType.Rss;

            // Creates Xml file.
            string xmlFile = HttpContext.Current.Server.MapPath("~/feed.xml");
            using (var fileStream = new FileStream(xmlFile, FileMode.Create))
            {
                using (var streamWriter = new StreamWriter(fileStream, Encoding.UTF8))
                {
                    var xs = new XmlWriterSettings { Indent = true };
                    using (var xmlWriter = XmlWriter.Create(streamWriter, xs))
                    {
                        xmlWriter.WriteStartDocument();
                        if (_isCssStyles)
                        {
                            const string strPi = "type='text/css' href='/Contents/Styles/feedStyle.css'";
                            // Write processor information
                            xmlWriter.WriteProcessingInstruction("xml-stylesheet", strPi);
                        }
                        if (_isRssFeed)
                        {
                            // RSS 2.0
                            var rssFormatter = new Rss20FeedFormatter(_feed, true);
                            rssFormatter.WriteTo(xmlWriter);
                        }
                        else
                        {
                            // Atom 1.0
                            var atomFormatter = new Atom10FeedFormatter(_feed);
                            atomFormatter.WriteTo(xmlWriter);
                        }
                    }
                }
            }
            //Display Xml file in browser.
            response.Clear();
            response.Buffer = true;
            response.Charset = "";
            response.Cache.SetCacheability(HttpCacheability.NoCache);
            response.ContentType = "text/xml";
            response.WriteFile(HttpContext.Current.Server.MapPath("~/feed.xml"));
            response.Flush();
            response.End();
        }
开发者ID:rriwaj,项目名称:rss-feed-wcf,代码行数:45,代码来源:RssResult.cs

示例15: 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


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