替代到Response.End()? [英] Alternative to Response.End()?

查看:292
本文介绍了替代到Response.End()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处理一个请求begin_request。目前我使用到Response.End()从做其他任何停止asp.net。到Response.End()抛出一个异常是有一个非例外办法可以终止请求?

I handle a request begin_request. At the moment i use Response.End() to stop asp.net from doing whatever else. Response.End() throws an exception is there a non exception way i can end the request?

如果你想知道为什么我没有文件的BC我告诉nginx的通过HTTP响应头服务于哪些文件因此,我闲来无事在asp.net做。到Response.End投有收集堆栈信息和所有的异常。我显然不需要这一点,从我过去的问题,我知道抛出异常昂贵。那么,我该怎么办哪?

If your wondering why i have no file its bc i tell nginx what file to serve via http response header thus i have nothing else to do in asp.net. Response.End throws an exception which has to collect stack info and all of that. I obviously dont need that and from my past questions i know throwing exceptions are expensive. So how what can i do where?

推荐答案

的Htt presponse.End()抛出设计异常;它必须工作。

HttpResponse.End() throws an exception by design; it has to to work.

只有 ThreadAbortException 被抛出时,这是否是呈现响应结束线程。如果没有异常,反应并没有结束。

Only when the ThreadAbortException is thrown, does the thread that's rendering the response end. If there's no exception, the response doesn't end.

一个替代方法是调用 HttpContext.Current.ApplicationInstance.CompleteRequest 来代替。这将prevent进一步code从直接跳到 Application_EndRequest 事件执行。

One alternative would be to call HttpContext.Current.ApplicationInstance.CompleteRequest instead. This will prevent further code from executing by jumping straight to the Application_EndRequest event.

这篇关于替代到Response.End()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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