本文整理汇总了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;
}
示例2: Redirect
private IHttpHandler Redirect(HttpResponseBase response, string url)
{
response.AddHeader("Location", url);
response.StatusCode = 301;
response.End();
return null;
}
示例3: Deny
public void Deny(HttpResponseBase response)
{
Contract.Requires(response != null);
response.StatusCode = (int)HttpStatusCode.Forbidden;
response.StatusDescription = "403 Forbidden";
response.End();
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例9: HandleException
public void HandleException(HttpResponseBase response, Exception exception)
{
var route = _exceptionRouteProvider.GetRoute(exception);
if (route != null)
{
response.RedirectToRoute(route);
response.End();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}