kul1000
asked on
"response.redirect" redirecting the page it self???
Platform : win2000-IIS5.0
Some times "response.redirect" does not work correctly and don't redirect the correct url, It redirect the page on it self and all the transactions in this page repeat one more time??? This issue causes when user wait a lot of time in a page. Is this problem about session? But why?
Is this a bug?? What is the sollution??
Thanks.
------------------
This is correct:
page1.asp ----response.redirect("pag e2.asp")-- -> page2.asp
Sometimes this occures:
page1.asp ----response.redirect("pag e2.asp")-- --
^ |
|------------------------- ---------- ---------- --
why?????????
thanks
Some times "response.redirect" does not work correctly and don't redirect the correct url, It redirect the page on it self and all the transactions in this page repeat one more time??? This issue causes when user wait a lot of time in a page. Is this problem about session? But why?
Is this a bug?? What is the sollution??
Thanks.
------------------
This is correct:
page1.asp ----response.redirect("pag
Sometimes this occures:
page1.asp ----response.redirect("pag
^ |
|-------------------------
why?????????
thanks
ASKER
For example this page is a shopping basket(basket.asp). When I try to add a product in this basket(add.asp) !!some times!! It adds the product and call the add.asp again, and adds the second product?? It is not about my code, trust me!
ASKER
I tried this command but not it didn't work..
Maybe you are redirecting back and forth in your two pages.
When page1 loads it gets the instruction redirect to page2 and when page2 loads it gets the instruction to redirect back to page1.
Read through your code carefully maybe you missed something! :o)
When page1 loads it gets the instruction redirect to page2 and when page2 loads it gets the instruction to redirect back to page1.
Read through your code carefully maybe you missed something! :o)
ASKER
I write asp for 5 year. This is not about my code !
ASKER
I write asp for 5 year. This is not about my code !
Unless you are a God or can walk on water, never say "it is not about my code", your'e human not perfect...
Simple example;
<% Response.Buffer = true %>
<HTML>
<BODY>
<%
Response.Write "This is File1.asp and switching to File2.asp"
Response.Clear
Response.Redirect "File2.asp"
%>
</BODY>
</HTML>
The buffer is set to true, then cleared before the redirect. Also, in ASP version 3.0 the default value is True and the server will buffer the output. However, there is a quirk concerning the default value of Response.Buffer that is dependent upon how Windows 2000 (which contains IIS 5.0 and ASP 3.0) is initially installed on your computer. If you do a clean install, the default value will be True. If the install is an upgrade, the default value will be False.
Simple example;
<% Response.Buffer = true %>
<HTML>
<BODY>
<%
Response.Write "This is File1.asp and switching to File2.asp"
Response.Clear
Response.Redirect "File2.asp"
%>
</BODY>
</HTML>
The buffer is set to true, then cleared before the redirect. Also, in ASP version 3.0 the default value is True and the server will buffer the output. However, there is a quirk concerning the default value of Response.Buffer that is dependent upon how Windows 2000 (which contains IIS 5.0 and ASP 3.0) is initially installed on your computer. If you do a clean install, the default value will be True. If the install is an upgrade, the default value will be False.
agree with mgfranz, as suggested add
<% Response.Buffer = true %> at top
<% Response.Buffer = true %> at top
Try using this function instead of Response.redirect()...
Sub SafeRedirection(Byval a_strURL)
'************************* ********** ********** ********** ***
'** Function/Sub: SafeRedirection
'** Description: This function does the same thing as Response.Redirect, except that it
'** explicitly creates the headers to avoid a "Object Moved" message from
'** when a file tries to redirect to the same filename.
'** Returns:
'** Modifications:
'** 08/07/2001 Partha Initial Creation
'************************* ********** ****
Const DOUBLE_QUOTE = """"
If (Not IsNull (a_strURL)) And (Len(Trim(a_strURL)) > 0) Then
Response.Buffer = True
Response.Status = "302 Object moved"
Response.AddHeader "Location", a_strURL
Response.Write "<HTML><Head>"
Response.Write "<META HTTP-EQUIV=Refresh CONTENT=""" & DOUBLE_QUOTE & "0;URL=" & a_strURL & DOUBLE_QUOTE & ">"
Response.Write "<Script>window.location=' " & a_strURL & "';</Script>"
Response.Write "</Head>"
Response.Write "</HTML>"
End If
End Sub
- Partha
Sub SafeRedirection(Byval a_strURL)
'*************************
'** Function/Sub: SafeRedirection
'** Description: This function does the same thing as Response.Redirect, except that it
'** explicitly creates the headers to avoid a "Object Moved" message from
'** when a file tries to redirect to the same filename.
'** Returns:
'** Modifications:
'** 08/07/2001 Partha Initial Creation
'*************************
Const DOUBLE_QUOTE = """"
If (Not IsNull (a_strURL)) And (Len(Trim(a_strURL)) > 0) Then
Response.Buffer = True
Response.Status = "302 Object moved"
Response.AddHeader "Location", a_strURL
Response.Write "<HTML><Head>"
Response.Write "<META HTTP-EQUIV=Refresh CONTENT=""" & DOUBLE_QUOTE & "0;URL=" & a_strURL & DOUBLE_QUOTE & ">"
Response.Write "<Script>window.location='
Response.Write "</Head>"
Response.Write "</HTML>"
End If
End Sub
- Partha
Nice function partha, remember that this is going to run client-side and javascript must be enabled.
I have been creating client-side javascript at the serrver ffor a while now and it does solve a few problems.
I have been creating client-side javascript at the serrver ffor a while now and it does solve a few problems.
Thanks mgfranz - but it's exactly not my function. I got this function from the net while researching about the netscape "302 - object moved" problem (unfortunaly I don't remember the source). It works great for me (in a lot of cases I redirect to the same ASP page as part of design - "one page does one thing completely").
Client side scripting has also come a long way - these days client-side javascript is used in such a variety of ways (like menus and roll-overs), that people without their javascript enabled would miss most of the fun - I just bank on the fact that javascript is enabled - rest of the success lies with the user.
- Partha
Client side scripting has also come a long way - these days client-side javascript is used in such a variety of ways (like menus and roll-overs), that people without their javascript enabled would miss most of the fun - I just bank on the fact that javascript is enabled - rest of the success lies with the user.
- Partha
Yup, me too...
Although in a few instances I have been asked to verify that JS as well as cookies are enabled, then throw in a frames/no-frames and browser-check and you have more code inn verifying and checking than in the page! :-)
Although in a few instances I have been asked to verify that JS as well as cookies are enabled, then throw in a frames/no-frames and browser-check and you have more code inn verifying and checking than in the page! :-)
If you are using IIS 5.0 exclusively, you can use Server.Transfer instead of Response.Redirect
Yes go with server.transfer..
you need to know that you shouldn't send the http header to the client before redirecting.. but as far as I see it the problem might be in your code..
you need to know that you shouldn't send the http header to the client before redirecting.. but as far as I see it the problem might be in your code..
ASKER
No. problem is not about my code.
I used ParthaChoudhury's function every where in my pages and I listened the packets between server and my browser.
1. Browser calls "Page1.asp"
2. Web Server says "302 Moved Temporarily" go "Page1.asp"
3. Browser calls "Page1.asp"
4. web server says normal things
Please carefull, web server says "302 Moved Temporarily", but I use "302 Object Moved" every where like ParthaChoudhury's function. I have never write to response "302 Moved Temporarily".
Thanks
I used ParthaChoudhury's function every where in my pages and I listened the packets between server and my browser.
1. Browser calls "Page1.asp"
2. Web Server says "302 Moved Temporarily" go "Page1.asp"
3. Browser calls "Page1.asp"
4. web server says normal things
Please carefull, web server says "302 Moved Temporarily", but I use "302 Object Moved" every where like ParthaChoudhury's function. I have never write to response "302 Moved Temporarily".
Thanks
better you can paste the code with only the redirection part you are using in each of these pages Page1.asp & Page2.asp.
So that, we guys can suggest you a good solution. :-)
So that, we guys can suggest you a good solution. :-)
ASKER
redirectionPart
SayfayaGonder "SagMenu.asp"
Function SayfayaGonder(SayfaUrl)
Const DOUBLE_QUOTE = """"
Response.Buffer = True
Response.Status = "302 Object moved"
Response.AddHeader "Location", SayfaUrl
Response.Write "<HTML><Head>"
Response.Write "<META HTTP-EQUIV=Refresh CONTENT=""" & DOUBLE_QUOTE & "0;URL=" & SayfaUrl & DOUBLE_QUOTE & ">"
Response.Write "<Script>window.location=' " & SayfaUrl & "';</Script>"
Response.Write "</Head>"
Response.Write "</HTML>"
end function
SayfayaGonder "SagMenu.asp"
Function SayfayaGonder(SayfaUrl)
Const DOUBLE_QUOTE = """"
Response.Buffer = True
Response.Status = "302 Object moved"
Response.AddHeader "Location", SayfaUrl
Response.Write "<HTML><Head>"
Response.Write "<META HTTP-EQUIV=Refresh CONTENT=""" & DOUBLE_QUOTE & "0;URL=" & SayfaUrl & DOUBLE_QUOTE & ">"
Response.Write "<Script>window.location='
Response.Write "</Head>"
Response.Write "</HTML>"
end function
sorry, please paste your very first code which use directly Response.redirect and not using any other function.
maybe...
-------
when the method is post and an error occurs, the second time its redirected, web server is assuming the method is "get"
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q175318
--------
302 Moved Temporarily
The requested resource resides temporarily under a different URL.
Since the redirection may be altered on occasion, the client should
continue to use the Request-URI for future requests.
The URL must be given by the Location field in the response. Unless
it was a HEAD request, the Entity-Body of the response should
contain a short note with a hyperlink to the new URI(s).
If the 302 status code is received in response to a request using
the POST method, the user agent must not automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued.
Note: When automatically redirecting a POST request after
receiving a 302 status code, some existing user agents will
erroneously change it into a GET request.
-------
when the method is post and an error occurs, the second time its redirected, web server is assuming the method is "get"
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q175318
--------
302 Moved Temporarily
The requested resource resides temporarily under a different URL.
Since the redirection may be altered on occasion, the client should
continue to use the Request-URI for future requests.
The URL must be given by the Location field in the response. Unless
it was a HEAD request, the Entity-Body of the response should
contain a short note with a hyperlink to the new URI(s).
If the 302 status code is received in response to a request using
the POST method, the user agent must not automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued.
Note: When automatically redirecting a POST request after
receiving a 302 status code, some existing user agents will
erroneously change it into a GET request.
ASKER
Not POST I use only GET.
maybe
Response.Status = "302 Moved Temporarily"
Response.AddHeader "Location", SayfaUrl
instead of object moved
sorry if it not works though
This thread was in w3c
>
> 1) go to www.netflix.com
> -> see:
> 302 Moved Temporarily
> <html><head><title>302 Moved Temporarily</title></head>
> <body bgcolor="#FFFFFF">
> <p>This document you requested has moved temporarily.</p>
> <p>It's now at <a href="http://www.netflix.com/Default">http://www.netflix.com/D
> </body></html>
>
>
> Works fine with lynx.
That's a bug in the server. Contact the server administrator.
Do: telnet www.netflix.com 80
Then type: GET / HTTP/1.0
and press enter twice.
There's no content-type text/html, so plain text is supposed according to
the HTTP protocol standard. Press \ to toggle HTML.
That's not an argument that "works fine with lynx".
Response.Status = "302 Moved Temporarily"
Response.AddHeader "Location", SayfaUrl
instead of object moved
sorry if it not works though
This thread was in w3c
>
> 1) go to www.netflix.com
> -> see:
> 302 Moved Temporarily
> <html><head><title>302 Moved Temporarily</title></head>
> <body bgcolor="#FFFFFF">
> <p>This document you requested has moved temporarily.</p>
> <p>It's now at <a href="http://www.netflix.com/Default">http://www.netflix.com/D
> </body></html>
>
>
> Works fine with lynx.
That's a bug in the server. Contact the server administrator.
Do: telnet www.netflix.com 80
Then type: GET / HTTP/1.0
and press enter twice.
There's no content-type text/html, so plain text is supposed according to
the HTTP protocol standard. Press \ to toggle HTML.
That's not an argument that "works fine with lynx".
ASKER
if u write www.domain.com, server says "go /default.asp"
this is normal.
But I say to server "give me page1.asp" and after server makes all the transactions in "page1.asp" than say to me "go page1.asp". And Re call my browser to this page again ????
this is normal.
But I say to server "give me page1.asp" and after server makes all the transactions in "page1.asp" than say to me "go page1.asp". And Re call my browser to this page again ????
Where is Response.Redirect in this function?
Function SayfayaGonder(SayfaUrl)
Const DOUBLE_QUOTE = """"
Response.Buffer = True
Response.Status = "302 Object moved"
Response.AddHeader "Location", SayfaUrl
Response.Write "<HTML><Head>"
Response.Write "<META HTTP-EQUIV=Refresh CONTENT=""" & DOUBLE_QUOTE & "0;URL=" & SayfaUrl & DOUBLE_QUOTE
& ">"
Response.Write "<Script>window.location=' " & SayfaUrl & "';</Script>"
Response.Write "</Head>"
Response.Write "</HTML>"
end function
I see a server-side generated javascript, but no VBScript Redirect...
So unless you are forcing the page to not cache the page, it will reload from cache.
Plus I think you might have too many " in there, does this work?
SayfayaGonder "SagMenu.asp"
Does the " get passed in the argument?
Function SayfayaGonder(SayfaUrl)
Const DOUBLE_QUOTE = """"
Response.Buffer = True
Response.Status = "302 Object moved"
Response.AddHeader "Location", SayfaUrl
Response.Write "<HTML><Head>"
Response.Write "<META HTTP-EQUIV=Refresh CONTENT=""" & DOUBLE_QUOTE & "0;URL=" & SayfaUrl & DOUBLE_QUOTE
& ">"
Response.Write "<Script>window.location='
Response.Write "</Head>"
Response.Write "</HTML>"
end function
I see a server-side generated javascript, but no VBScript Redirect...
So unless you are forcing the page to not cache the page, it will reload from cache.
Plus I think you might have too many " in there, does this work?
SayfayaGonder "SagMenu.asp"
Does the " get passed in the argument?
ASKER
It doesn't change SayfaGonder "page1.asp" or response.redirect "page1.asp". Same problem. I think problem on web server.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My problem is this.I will say again:
"Sometimes" When
response.redirect "a.asp"
command is work, page redirect it self. Not goes "a.asp". So I think this is a bug.
"Sometimes" When
response.redirect "a.asp"
command is work, page redirect it self. Not goes "a.asp". So I think this is a bug.
ok try with location.href you dont get problem,
<%
'can have asp codes here....
'at last instead of using Response.Redirect use below script
%>
<script language=javascript>
location.href="page2.asp"
</script>
tyr this ....!
<%
'can have asp codes here....
'at last instead of using Response.Redirect use below script
%>
<script language=javascript>
location.href="page2.asp"
</script>
tyr this ....!
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I appreciate any comments that would help me to make a recommendation.
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
GaryC123
EE Cleanup Volunteer
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
GaryC123
EE Cleanup Volunteer
Split between manihopever and mgfranz
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Split Points - manihopever / mgfranz
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
GaryC123
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
Split Points - manihopever / mgfranz
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
GaryC123
EE Cleanup Volunteer
Before issue an command Redirect you should clear the response buffer by response.clear() method.