我继承了一个经典的ASP网站,这个网站已经出现了一个奇怪的问题。在页面顶部,它重定向到https以获得安全连接。代码是:
<%
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
%>
此代码位于文件的顶部。在此之前没有任何事情。当我打开浏览器并加载页面时,我老去了:
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.
没有重定向发生。如果我重新加载页面或离开并在错误之后返回,那么一切正常,直到我关闭浏览器并重新打开它。
如果这位于文件的顶部,那么如何编写标题?
更新:IE8视图源提供的完整源代码:
<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="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>
是之前的空间
答案 0 :(得分:1)
请参阅http://support.microsoft.com/kb/159402
在Response.Clear
之后添加Response.End
和Response.Redirect
之后添加{{1}}。