0

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()

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?

4

1 回答 1

2

通过在页脚中设置这些,对于大多数浏览器来说,您可能为时已晚——您需要在页眉中发送它,而此时页眉已经发送。最好在任何页面输出发生之前处理这种情况。

如果你不能这样做,那么你需要缓冲整个页面,并在遇到该条件时在重定向之前清除缓冲区:

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
于 2013-01-22T08:14:43.610 回答