PDA

View Full Version : response.redirect issue


NancyJ
06-02-2005, 06:01 PM
I'm trying to response.redirect from my form processing page back to the previous page however I get this error:
Redirection limit for this url exceeded. Unable to load the requested page. This could be caused by cookies that are blocked.

I remember having this once before but I cant remember what the issue was or how I solved it...


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
if len(session("items")) <= 0 then
response.redirect "products.asp"
end if
Dim arrTempOrder, boolFound
boolFound = False
arrTempOrder = session("order")

for i = 0 to ubound(arrTempOrder)
response.write i
if request.form("ID") = cstr(arrTempOrder(i, 0)) and cstr(arrTempOrder(i, 1)) = request.form("Size") then
arrTempOrder(i, 2) = arrTempOrder(i, 2) + 1
boolFound = True
end if
next
session("counter") = session("counter") +1
if boolFound = False then
arrTempOrder(session("counter")-1, 0) = request.form("ID")
arrTempOrder(session("counter")-1, 1) = request.form("Size")
arrTempOrder(session("counter")-1, 2) = 1

end if

session("items") = session("items") +1
session("total") = session("total") + cInt(request.form("Price"))
session("order") = arrTempOrder

response.redirect Request.ServerVariables("HTTP_REFERRER")&"?"&request.ServerVariables("QUERY_STRING")

%>

Freon22
06-02-2005, 09:03 PM
I did notice one thing you have an error in

response.redirect Request.ServerVariables("HTTP_REFERRER")&"?"&request.ServerVariables("QUERY_STRING")

It should be

response.redirect Request.ServerVariables("HTTP_REFERER")&"?"&request.ServerVariables("QUERY_STRING")

One two many Rs :) also the
Request.ServerVariables("HTTP_REFERER") will get the whole line so your querystring will already be in it. But if you want get the string on the redirected page you would need to request.ServerVariables("QUERY_STRING") to pull out the querystring.

Morgoth
06-03-2005, 07:27 AM
But if you want get the string on the redirected page you would need to request.ServerVariables("QUERY_STRING") to pull out the querystring.

I see what you're saying, but you'll need to explain it a bit better for NancyJ to understand.

Here are 3 files that will help explain the problem:
A.asp<a href="b.asp?query=string">B.ASP?Query=String</a>A.asp Results:B.ASP?Query=StringB.asp<a href="c.asp">C.ASP</a>B.asp Results: (Now has a QueryString: http://127.0.0.1/b.asp?query=string)C.ASPC.asp<%
Dim strURL
strURL = Request.ServerVariables("HTTP_REFERER")
Response.Write strURL
Response.Write "<br>FIX:<br>"
Response.Write Mid(strURL, 1, InStr(1, strURL, "?") - 1)
%>C.asp Results:http://127.0.0.1/b.asp?query=string
FIX:
http://127.0.0.1/b.asp

That should do it. Reply if you have any questions.

NancyJ
06-03-2005, 11:43 AM
I see what you're saying, but you'll need to explain it a bit better for NancyJ to understand.

Thanks but I understood him perfectly. In fact your 'example' was far more confusing.

Thanks Freon, its working fine now :)

Freon22
06-03-2005, 02:26 PM
Your welcome Nancy, I've readed some of your post so I new your coding was good that left syntax or spelling error.

NancyJ
06-03-2005, 03:41 PM
Your welcome Nancy, I've readed some of your post so I new your coding was good that left syntax or spelling error.
spelling was never my forte heh ;)