How to fix issue with Response.redirect custom code on V8.1xx onwards

How to fix issue with Response.redirect custom code on V8.1xx onwards

If you are using v8.1xx onwards, and if you have any custom code that need to do 'response.redirect' to another page that you put after the shoppageheader routine, it will throw error message like below :

Response object error 'ASP 0156 : 80004005'
Header Error
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.

Example of possible code using response.redirect that will cause the above error msg eg. :

ShopPageHeader
response.redirect "yourotherpage.asp"

This is because since v8.1xx onwards, we have applied the 'response.flush' on shopheaders.asp.
Our purpose to add this is for speed enhancement (Time To First Byte) and this TTFB is aimed to improve search engine ranking.

You can read more about TTFB and relation to search engine ranking at :
https://moz.com/blog/improving-search-rank-by-optimizing-your-time-to-first-byte

Now, as we have implemented the 'response.flush' on shopheaders.asp, if you have any custom code that need to do 'response.redirect' to another page, here is the solution :
1. Open your file that have this custom code 'response.redirect' using notepad or text editor.

2. Locate your response.redirect code eg:

response.redirect "yourotherpage.asp"

3. Please replace entire line to :

session("customerpagehashstring") = generatecheckouthasstring
JSredirect "yourotherpage.asp"

4. At very bottom of your file before the closing asp tag %>, insert this new routine :

sub JSredirect(URLx)
%>
<script language="javascript" type="text/javascript">
<!--
window.parent.location.href='<%=URLx%>';
-->
</script>
<noscript>
Please click <a href="<%=URLx%>">here </a>to proceed.
</noscript>
</body>
</html>
<%
end sub

5. Save the file and upload to your site.


Times Viewed:
1933
Added By:
Wilson Keneshiro
Date Created:
8/19/2016
Last Updated:
8/19/2016