Redirection Not Working Classic Asp Site

拟墨画扇 提交于 2019-12-13 05:25:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!