Вопрос

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?

Это было полезно?

Решение

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top