472,139 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,139 software developers and data experts.

IsPostBack but in ASP

Seb
Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Thanks

Sebastien


Oct 3 '07 #1
6 8306
"Seb" <a@a.frwrote in message
news:47***********************@news.free.fr...
Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Thanks

Sebastien
Function IsPostBack()
IsPostBack = (Request.ServerVariables("REQUEST_METHOD") = "POST")
End Function


--
Anthony Jones - MVP ASP/ASP.NET
Oct 4 '07 #2
Hello

Sorry but it's good to detect a POST but not to detect a refresh.

Thanks

Sebastien

"Anthony Jones" wrote:
"Seb" <a@a.frwrote in message
news:47***********************@news.free.fr...
Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Thanks

Sebastien

Function IsPostBack()
IsPostBack = (Request.ServerVariables("REQUEST_METHOD") = "POST")
End Function


--
Anthony Jones - MVP ASP/ASP.NET
Oct 4 '07 #3
"Seb" <a@a.frwrote in message
news:47***********************@news.free.fr...
Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Will something lke this work for you?

It uses Session variables to identify the current page
and its counter.

Create "refresh1.asp" then copy it to "refresh2.asp"
and change the value of "cASP" to "refresh2.asp".

Call it via http://{your domain}/refresh1.asp then
click the links and watch the page+counter display.
Clicking "Refresh" will increment the counter as well.

<%@ Language="VBScript" %>
<% Option Explicit
Const cASP = "refresh1.asp"
If Session("ASP") <cASP _
Or Session("CTR") = "" Then
Session("CTR") = 0
Else
Session("CTR") = Session("CTR") + 1
End If
Session("ASP") = cASP
%>
<html>
<body>
<%=Session("ASP")%: <%=Session("CTR")%>
<hr>
<a href="refresh1.asp">1</a| <a href="refresh2.asp">2</a>
</body>
</html>
Oct 4 '07 #4
?
Not even .Net's IsPostBack method can distinguish between an initial
page request and a subsequent page refresh ...

To do that, you will probably need to use a session variable to track
when the page is initially requested

Seb wrote:
Hello

Sorry but it's good to detect a POST but not to detect a refresh.

Thanks

Sebastien

"Anthony Jones" wrote:
>"Seb" <a@a.frwrote in message
news:47***********************@news.free.fr...
>>Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Thanks

Sebastien

Function IsPostBack()
IsPostBack = (Request.ServerVariables("REQUEST_METHOD") = "POST")
End Function


--
Anthony Jones - MVP ASP/ASP.NET
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 4 '07 #5
"Seb" <Se*@discussions.microsoft.comwrote in message
news:F6**********************************@microsof t.com...
Hello

Sorry but it's good to detect a POST but not to detect a refresh.

Thanks

Sebastien
I see. Most refreshes are accompanied with a pragma: no-cache header but
that isn't guaranteed nor is it guaranteed that the initial request will not
be accompanied by the header.

The best way to ensure you don't reprocess the same post is to add a hidden
field containing a unique ID (such as a GUID) to the form.

When you've processed the POST of the form make a record of the UniqueID to
mark that its been processed. Before processing a POST check that you
haven't got a record of that POST already.

--
Anthony Jones - MVP ASP/ASP.NET
Oct 4 '07 #6
Thank you everybody

Finally I have used a Session variable to save the last post but it's not a
unique ID because my unique ID is calculated when I have a new post.

By
Sébastien
"Anthony Jones" wrote:
"Seb" <Se*@discussions.microsoft.comwrote in message
news:F6**********************************@microsof t.com...
Hello

Sorry but it's good to detect a POST but not to detect a refresh.

Thanks

Sebastien

I see. Most refreshes are accompanied with a pragma: no-cache header but
that isn't guaranteed nor is it guaranteed that the initial request will not
be accompanied by the header.

The best way to ensure you don't reprocess the same post is to add a hidden
field containing a unique ID (such as a GUID) to the form.

When you've processed the POST of the form make a record of the UniqueID to
mark that its been processed. Before processing a POST check that you
haven't got a record of that POST already.

--
Anthony Jones - MVP ASP/ASP.NET
Oct 5 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tim | last post: by
2 posts views Thread by patrick_a | last post: by
3 posts views Thread by Alan Pretre | last post: by
2 posts views Thread by Pravin | last post: by
4 posts views Thread by TJ | last post: by
6 posts views Thread by RA | last post: by
5 posts views Thread by David Lozzi | last post: by
5 posts views Thread by BM | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.