重定向不工作传统的ASP网站 [英] Redirection Not Working Classic Asp Site

查看:137
本文介绍了重定向不工作传统的ASP网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个网站,我的主机是目前正在建设,所以我想所有页面重定向回主页。我使用下面的code重定向:

A site i host is currently under construction so i am trying to redirect all pages back to the homepage. I am using the following code for redirection:

Response.Status = "302 Moved Temporary"
Response.AddHeader "Location", "http://www.soundczar.com" 
Response.End()

然而,这是能够正确地重定向唯一的浏览器是Opera。火狐,IE和Chrome都无法重定向的页​​面。上周我有同样的问题与其他传统的ASP网站。我把这个code。在页脚SSI的结束。有什么建议?

However, the only browser that is able to redirect properly is Opera. Firefox, IE, and Chrome are unable to redirect the pages. I had the same issue last week with another classic asp site. I placed this code at the end of the footer SSI. Any suggestions?

推荐答案

通过设置那些在页脚,你可能为时已晚,大多数浏览器 - 你需要它在头发送,头就已经被然后发送。最好的任何页面输出发生之前处理的条件。

By setting those in the footer, you are probably too late for most browsers -- you need it sent in the header, and headers will already be sent by then. Best to handle the condition before any page output happens.

如果你不能做到这一点,那么你就需要缓冲整个页面,并重定向之前清空缓冲区,当你打的条件:

If you can't do that, then you'll need to buffer the whole page, and clear the buffer before redirecting when you hit that condition:

Response.Buffer = True

Other_Code_Here()

If redirect_condition Then
    Response.Clear
    Response.Status = "302 Moved Temporary"
    Response.AddHeader "Location", "http://www.soundczar.com"
    Response.End()
End If

这篇关于重定向不工作传统的ASP网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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