开发者

Cassic ASP in VB Redirect issues

I've inherited a classic ASP site that has developed an odd problem. At the top of the page its redirecting to https for a secure connections. The code is:

<%
Response.Buffer = True

' Redirect to SSL if needed:
servername=Request.ServerVariables("SERVER_NAME")
scriptname=Request.ServerVariables("SCRIPT_NAME")
serverport=Request.ServerVariables("SERVER_PORT")

if serverport="80" and (InStr(servername, "192.168.1.") = 0 and servername <> "localhost")  then
    Response.Redirect "https://www.theurl.com" & scriptname & "?package=" + Request.QueryString("package")
else
    'response.Write("Development testing")
end if

%>

This code is at the top of the file. Nothing is before this. When I open the browser and load up the page I age a:

Response object error 'ASP 0156 : 80004005'

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content. 

No redirect happend. If I reload the page or go away and come back after the error then everything works just fine until I close the browser and reopen it.

If this is at the top of the file how can the headers already be written?

Update: The full source as provided by IE8's view source:

 <font face="Arial" size=2>
<p>Response object</font> <font face="Arial" size=2>error 'ASP 0156 : 80004005'</font>
<p>
<font face="Arial" size=2>Header Error</font>
<p>
<font face="Arial" size=2>/path/file.asp</font><font face="开发者_JAVA百科Arial" size=2>, line 10</font>
<p>
<font face="Arial" size=2>The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
</font> 

Yes the space before


See http://support.microsoft.com/kb/159402

Add Response.Clear before and Response.End after the Response.Redirect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜