ASP.Net:如何在浏览器断开停止执行页? [英] ASP.Net: How to stop page execution when browser disconnects?

查看:147
本文介绍了ASP.Net:如何在浏览器断开停止执行页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果浏览器请求一个ASP.Net页面,然后用户点击停止或导航的时候,我虽然该浏览器将关闭连接和ASP.Net或许会停止执行。我不认为这是因为Dispose()方法时,我测试这不叫的情况。反正是有知道当浏览器/客户端已断开连接,然后从执行?

If a browser requests an ASP.Net page and then the user clicks "stop" or navigates away, I though that the browser would close the connection and ASP.Net would perhaps stop execution. I don't think that's the case since Dispose() is not called when I test this. Is there anyway to know when the browser/client has disconnected and then stop the page from executing?

推荐答案

您可以检查 IsClientConnected

    if (!Response.IsClientConnected){
        HttpContext.Current.Response.End();
        return;
    }

这篇关于ASP.Net:如何在浏览器断开停止执行页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆