Response.End(); 用HttpContext.Current.ApplicationInstance.CompleteRequest 代替

Response.End(); 会报异常

HttpContext.Current.ApplicationInstance.CompleteRequest

这里有个讨论的帖子很有意思:http://q.cnblogs.com/q/32216/

时间: 2024-08-03 08:36:31

Response.End(); 用HttpContext.Current.ApplicationInstance.CompleteRequest 代替的相关文章

asp.net后台导出excel的方法:使用System.Web.HttpContext.Current.Response导出excel

程序如下: 程序描述:该程序能够实现有大型的标题,以及表头等功能 调用方法:ToExcel(newDt, FileName); protected void ToExcel(DataTable dt, string FileName) { StringBuilder sb = new StringBuilder(); sb.Append("<style type=\"text/css\">"); sb.Append("<!--"

gridview汇出EXCEL (ExportGridViewToExcel(dt, HttpContext.Current.Response);)

调用 ExportGridViewToExcel(dt, HttpContext.Current.Response); private void ExportGridViewToExcel(DataTable tb, HttpResponse response) { response.Clear(); response.Charset = ""; response.AppendHeader("Content-Disposition", "attachmen

HttpContext.Current.Session 和 Session 的区别

Session(会话)通常指一个动作从开始到结束不间断的一个动作. 例如“打电话”,通常是“1.拿起电话--2.拨对方号码--3.对方截图--4.挂机”.这四个步骤从完成到结束组成了一个基本的Session,中间任何一步断裂,都会导致Session的失效. 而在浏览器里,Session主要通过连接传递,“打开购物--点击连接选择物品--添加到购物车--结账”组成了一个Session,在不使用Cookie的情况下,中间任何一步断裂都会Session失效. 所有,你用浏览器打开2个页面,在一个页面里

慎用System.Web.HttpContext.Current

每当控制流离开页面派生的Web表单上的代码的时候,HttpContext类的静态属性Current可能是有用的. 使用这个属性,我们可以获取当前请求(Request),响应(Response),会话(Session,)和应用程序对象(Application objects)以及请求更多服务. 以下面的代码为例. private void Page_Load(object sender, System.EventArgs e) { MyClass myClass = new MyClass();

HttpContext.Current.Session.SessionID相关问题及备忘

今天Tony提到说我们系统中会利用如下代码来判断用户是否过期. if (string.IsNullOrEmpty(UserContext.ConnectionSessionId)) { LogUIFactory.Current.Debug(HEARTBEAT_DISCONNECTION_LOG_2); timeout = true; } 但是我做实验发现,在page load的时候,打印出来的sessionid是一直在变化的: protected void Page_Load(object se

HttpContext.Current并非无处不在

原文地址:http://www.cnblogs.com/fish-li/archive/2013/04/06/3002940.html 阅读目录 开始 无处不在的HttpContext HttpContext.Current到底保存在哪里? HttpContext并非无处不在! 如何获取文件绝对路径? 异步调用中如何访问HttpContext? 安全地使用HttpContext.Current 了解ASP.NET的开发人员都知道它有个非常强大的对象 HttpContext,而且为了方便,ASP.

HttpContext.Current.Cache 过期时间

原文:HttpContext.Current.Cache 过期时间 为了更快的读取数据,我们一般会把常用到的数据加载到Cache中 在.NET中,Cache的存在可以依赖多中方式,主要用到HttpContext.Current.Cache类 在这里,我主要写几种依赖方式 1:不依赖任何条件 HttpContext.Current.Cache.Insert(string cacheName,object obj) 理论上是Cache会永久保存,但是当服务器重新启动,内存紧张的时候也会丢失. 2:H

HttpContext.Current.Items的用途

HTTP是一个无状态的协议.每次的请求都是独立的,它的执行情况和结果与前面的请求和之后的请求是无直接关系的,它不会受前面的请求应答情况直接影响,也不会直接影响后面的请求应答情况.而实际上,我们的系统往往要支持用户在客户端浏览器和服务端之间的多次请求共用相同的数据(状态),比如用户的登陆账号信息.于是乎,ASP.NET提供了很多变量来管理状态:比如application state,session state,view state等.HttpContext对象只针对一个单一的http请求.这个类的

Cache及(HttpRuntime.Cache与HttpContext.Current.Cache)

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/avon520/archive/2009/11/25/4872704.aspx .NET中Cache有两种调用方式:HttpContext.Current.Cache 和 HttpRuntime.Cache,这两种方式有什么区别呢?我们先看MSDN上的解释:      HttpContext.Current.Cache:为当前 HTTP 请求获取Cache对象.      HttpRuntime.Cache:获取当前