问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/14453115/redirection-not-working-classic-asp-site