简体   繁体   English

ASP-Classic-如何清除Response.Redirect放置在其中的重定向标头?

[英]ASP-Classic - how can I clear out a redirect header put there by Response.Redirect?

I'm working with a compiled VB6 object called by an ASP page. 我正在使用ASP页调用的已编译VB6对象。 Response buffering is on. 响应缓冲已打开。 My code calls another compiled VB component, which may call Response.Redirect(), but continue executing and return control to my code. 我的代码调用了另一个已编译的VB组件,该组件可能调用Response.Redirect(),但继续执行并将控制权返回给我的代码。 I may then want to call Response.redirect myself. 然后,我可能想自己打电话给Response.redirect。 However, this seems to create an array for the header, rather than overwriting the previous Url: 但是,这似乎是为标头创建一个数组,而不是覆盖以前的Url:

Code: 码:

  Call m_oResponse.Redirect("http://google.com")
  Call m_oResponse.Redirect("http://yahoo.com")

Resulting http response: 产生的http响应:

 HTTP/1.1 302 Object moved
 ...
 Location: http://google.com,http://yahoo.com
 ...
 Date: Wed, 23 Mar 2011 18:14:17 GMT
 Connection: keep-alive

I tried Response.Clear, but this doesn't seem to affect the headers. 我尝试了Response.Clear,但这似乎并不影响标题。

As far as I know Response.Redirect() terminates the processing of the page and does the redirect immediately. 据我所知, Response.Redirect()终止页面的处理并立即进行重定向。 Generally your code cannot continue processing afterwards so there is nothing you can do to avoid the redirect. 通常,您的代码此后无法继续处理,因此您无法做任何避免重定向的操作。

MSDN says: MSDN说:

Any response body content such as displayed HTML text or Response.Write text in the page indicated by the original URL is ignored. 原始URL指示的页面中的任何响应正文内容(例如显示的HTML文本或Response.Write文本)都将被忽略。 However, this method does send other HTTP headers set by this page indicated by the original URL to the client. 但是,此方法会将由原始URL指示的此页面设置的其他HTTP标头发送到客户端。 An automatic response body containing the redirect URL as a link is generated. 生成包含重定向URL作为链接的自动响应正文。

http://msdn.microsoft.com/en-us/library/ms524309.aspx http://msdn.microsoft.com/en-us/library/ms524309.aspx

The only way I can think that you could get code to continue executing afterwards would be to invoke a compiled COM component or some other external process as that would not be affected by the page execution being terminated. 我认为可以让代码在以后继续执行的唯一方法是调用已编译的COM组件或某些其他外部进程,因为这不会受到终止页面执行的影响。

If the VB component you mention is an external component and not just another ASP file included with an <!--#include file="other_script.asp"--> directive then it will continue executing but your calling ASP page won't. 如果您提到的VB组件是一个外部组件,而不仅仅是<!--#include file="other_script.asp"-->指令中包含的另一个ASP文件,则它将继续执行,但您调用的ASP页面不会执行。

Do you have the source for the compiled component? 您有已编译组件的源代码吗?

ie could it be rewritten to, instead of causing the redirection itself, just simply return the URL to redirect to? 即可以将其重写为,而不是直接引起重定向,而只需返回URL即可重定向到?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM