IsPostBack but in ASP

Hello,

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


Thanks

Sebastien
Seb [ Mi, 03 Oktober 2007 22:00 ] [ ID #1835017 ]

Re: IsPostBack but in ASP

"Seb" <a [at] a.fr> wrote in message
news:4703f4e6$0$14466$426a74cc [at] 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
Anthony Jones [ Do, 04 Oktober 2007 09:38 ] [ ID #1836275 ]

Re: IsPostBack but in ASP

Hello

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

Thanks

Sebastien



"Anthony Jones" wrote:

> "Seb" <a [at] a.fr> wrote in message
> news:4703f4e6$0$14466$426a74cc [at] 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
>
>
>
Seb [ Do, 04 Oktober 2007 10:19 ] [ ID #1836276 ]

Re: IsPostBack but in ASP

"Seb" <a [at] a.fr> wrote in message
news:4703f4e6$0$14466$426a74cc [at] 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.

<% [at] 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>
1 | 2
</body>
</html>
McKirahan [ Do, 04 Oktober 2007 14:25 ] [ ID #1836282 ]

Re: IsPostBack but in ASP

?
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 [at] a.fr> wrote in message
>> news:4703f4e6$0$14466$426a74cc [at] 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.
reb01501 [ Do, 04 Oktober 2007 14:18 ] [ ID #1836283 ]

Re: IsPostBack but in ASP

"Seb" <Seb [at] discussions.microsoft.com> wrote in message
news:F6DCB5FC-78EB-49B5-A6B2-7364DDCB6A80 [at] microsoft.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
Anthony Jones [ Do, 04 Oktober 2007 19:10 ] [ ID #1836292 ]

Re: IsPostBack but in ASP

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" <Seb [at] discussions.microsoft.com> wrote in message
> news:F6DCB5FC-78EB-49B5-A6B2-7364DDCB6A80 [at] microsoft.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
>
>
>
Seb [ Fr, 05 Oktober 2007 10:14 ] [ ID #1837441 ]
Webserver » microsoft.public.inetserver.asp.general » IsPostBack but in ASP

Vorheriges Thema: Why this ASP code all of the sudden stopped working?
Nächstes Thema: Focus on element not working correctly