467,923 Members | 1,459 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,923 developers. It's quick & easy.

Class not getting destroyed on Redirect

Hello,

I have a page that creates a class, and then on certain conditions,
redirects user to another page. The class has a Class_Terminate() function
that saves itself to a database. The class comes from an includes ASP file,
it isn't a COM object.

Here's my code outline (not actual code for brevity - in otherwords, there
may be syntax errors, but that's not the cause of the problem)

<!--#include file="myclass.asp">
<%
objClass = new cMyClass
cMyClass.variable = "Somethign"

if (somecondition) then
response.redirect("someotherpage.asp")
end if

%>
The problem I am having is that if the page does not redirect, cMyClass's
Class_Terminate function is run, however, if the redirect statement is run,
Class_Terminate doesn't get run.

Is this a known problem in ASP classic?
Jul 19 '05 #1
  • viewed: 1908
Share:
5 Replies
Try:

Set objClass = new cMyClass
cMyClass.variable = "Somethign"

if (somecondition) then
Set objClass=Nothing
response.redirect("someotherpage.asp")
end if
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Steve Lutz" <sl***@comcast.net> wrote in message
news:eF**************@TK2MSFTNGP12.phx.gbl...
Hello,

I have a page that creates a class, and then on certain conditions,
redirects user to another page. The class has a Class_Terminate() function
that saves itself to a database. The class comes from an includes ASP file, it isn't a COM object.

Here's my code outline (not actual code for brevity - in otherwords, there
may be syntax errors, but that's not the cause of the problem)

<!--#include file="myclass.asp">
<%
objClass = new cMyClass
cMyClass.variable = "Somethign"

if (somecondition) then
response.redirect("someotherpage.asp")
end if

%>
The problem I am having is that if the page does not redirect, cMyClass's
Class_Terminate function is run, however, if the redirect statement is run, Class_Terminate doesn't get run.

Is this a known problem in ASP classic?

Jul 19 '05 #2
Hi, I guess I should clarify, I was trying to generalize the problem..

The object I'm using is going to be used globally through-out the site to
ensure user is logged in. To make future pages easier to code, the object
Class_initialize function reads cookies, and attempts to authenticate the
user. If unable to, then the user is redirected to an login page. Since it
is the class itself doing the redirect, then it isn't possible for the class
to destroy itself.

<!--#include file="myclass.asp">
<%
objClass = new cMyClass

' If I get here then the user is logged in.

%>


"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:un**************@TK2MSFTNGP10.phx.gbl...
Try:

Set objClass = new cMyClass
cMyClass.variable = "Somethign"

if (somecondition) then
Set objClass=Nothing
response.redirect("someotherpage.asp")
end if
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Steve Lutz" <sl***@comcast.net> wrote in message
news:eF**************@TK2MSFTNGP12.phx.gbl...
Hello,

I have a page that creates a class, and then on certain conditions,
redirects user to another page. The class has a Class_Terminate() function that saves itself to a database. The class comes from an includes ASP

file,
it isn't a COM object.

Here's my code outline (not actual code for brevity - in otherwords, there may be syntax errors, but that's not the cause of the problem)

<!--#include file="myclass.asp">
<%
objClass = new cMyClass
cMyClass.variable = "Somethign"

if (somecondition) then
response.redirect("someotherpage.asp")
end if

%>
The problem I am having is that if the page does not redirect, cMyClass's Class_Terminate function is run, however, if the redirect statement is

run,
Class_Terminate doesn't get run.

Is this a known problem in ASP classic?


Jul 19 '05 #3
put the redirect into the include file outside of the class

'class definition here

Dim objClass
Set objClass = new cMyClass

if (objClass.mustredirect() ) then
Set objClass=Nothing
response.redirect("someotherpage.asp")
end if

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Steve Lutz" <sl***@comcast.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi, I guess I should clarify, I was trying to generalize the problem..

The object I'm using is going to be used globally through-out the site to
ensure user is logged in. To make future pages easier to code, the object
Class_initialize function reads cookies, and attempts to authenticate the
user. If unable to, then the user is redirected to an login page. Since it
is the class itself doing the redirect, then it isn't possible for the class to destroy itself.

<!--#include file="myclass.asp">
<%
objClass = new cMyClass

' If I get here then the user is logged in.

%>


"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:un**************@TK2MSFTNGP10.phx.gbl...
Try:

Set objClass = new cMyClass
cMyClass.variable = "Somethign"

if (somecondition) then
Set objClass=Nothing
response.redirect("someotherpage.asp")
end if
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Steve Lutz" <sl***@comcast.net> wrote in message
news:eF**************@TK2MSFTNGP12.phx.gbl...
Hello,

I have a page that creates a class, and then on certain conditions,
redirects user to another page. The class has a Class_Terminate() function that saves itself to a database. The class comes from an includes ASP

file,
it isn't a COM object.

Here's my code outline (not actual code for brevity - in otherwords, there may be syntax errors, but that's not the cause of the problem)

<!--#include file="myclass.asp">
<%
objClass = new cMyClass
cMyClass.variable = "Somethign"

if (somecondition) then
response.redirect("someotherpage.asp")
end if

%>
The problem I am having is that if the page does not redirect, cMyClass's Class_Terminate function is run, however, if the redirect statement is

run,
Class_Terminate doesn't get run.

Is this a known problem in ASP classic?



Jul 19 '05 #4
Hi Mark,

Thanks for the assistance, but this isn't the functionality I need. I need
to write a foundation for the site so junior developers can concentrate on
UI issues and not the application. Oh.. but I guess I just thought of a
workaround:

The include file that has the object in it, actual creates an instance of
the object as well (outside of the class definition). So after I create it,
I'll just see if it needed to redirect...

Question though, are classes supposed get destroyed when a redirect happens?
Do they get destroyed by the Class_Terminate isn't called?

Steve
"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
put the redirect into the include file outside of the class

'class definition here

Dim objClass
Set objClass = new cMyClass

if (objClass.mustredirect() ) then
Set objClass=Nothing
response.redirect("someotherpage.asp")
end if

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Steve Lutz" <sl***@comcast.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi, I guess I should clarify, I was trying to generalize the problem..

The object I'm using is going to be used globally through-out the site to ensure user is logged in. To make future pages easier to code, the object Class_initialize function reads cookies, and attempts to authenticate the user. If unable to, then the user is redirected to an login page. Since it is the class itself doing the redirect, then it isn't possible for the

class
to destroy itself.

<!--#include file="myclass.asp">
<%
objClass = new cMyClass

' If I get here then the user is logged in.

%>


"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:un**************@TK2MSFTNGP10.phx.gbl...
Try:

Set objClass = new cMyClass
cMyClass.variable = "Somethign"

if (somecondition) then
Set objClass=Nothing
response.redirect("someotherpage.asp")
end if
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Steve Lutz" <sl***@comcast.net> wrote in message
news:eF**************@TK2MSFTNGP12.phx.gbl...
> Hello,
>
> I have a page that creates a class, and then on certain conditions,
> redirects user to another page. The class has a Class_Terminate()

function
> that saves itself to a database. The class comes from an includes ASP file,
> it isn't a COM object.
>
> Here's my code outline (not actual code for brevity - in otherwords,

there
> may be syntax errors, but that's not the cause of the problem)
>
> <!--#include file="myclass.asp">
> <%
> objClass = new cMyClass
> cMyClass.variable = "Somethign"
>
> if (somecondition) then
> response.redirect("someotherpage.asp")
> end if
>
> %>
>
>
> The problem I am having is that if the page does not redirect,

cMyClass's
> Class_Terminate function is run, however, if the redirect statement is run,
> Class_Terminate doesn't get run.
>
> Is this a known problem in ASP classic?
>
>



Jul 19 '05 #5
uh, Steve,

The work-around you came up with is what I was recommending.

As far a the class terminate on re-direction you might try a simpler
mechanism for determining if the terminate method fires or not. Possibly the
database access cannot take place once the page is out of scope. Try writing
out a flag to a file just to see if that is possible. I know that doesn't
resolve the actual issue you have but it may shed light on what is actually
happening.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Steve Lutz" <sl***@comcast.net> wrote in message
news:uW*************@tk2msftngp13.phx.gbl...
Hi Mark,

Thanks for the assistance, but this isn't the functionality I need. I need
to write a foundation for the site so junior developers can concentrate on
UI issues and not the application. Oh.. but I guess I just thought of a
workaround:

The include file that has the object in it, actual creates an instance of
the object as well (outside of the class definition). So after I create it, I'll just see if it needed to redirect...

Question though, are classes supposed get destroyed when a redirect happens? Do they get destroyed by the Class_Terminate isn't called?

Steve
"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
put the redirect into the include file outside of the class

'class definition here

Dim objClass
Set objClass = new cMyClass

if (objClass.mustredirect() ) then
Set objClass=Nothing
response.redirect("someotherpage.asp")
end if

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Steve Lutz" <sl***@comcast.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi, I guess I should clarify, I was trying to generalize the problem..

The object I'm using is going to be used globally through-out the site to ensure user is logged in. To make future pages easier to code, the object Class_initialize function reads cookies, and attempts to authenticate the user. If unable to, then the user is redirected to an login page. Since
it
is the class itself doing the redirect, then it isn't possible for the class
to destroy itself.

<!--#include file="myclass.asp">
<%
objClass = new cMyClass

' If I get here then the user is logged in.

%>


"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:un**************@TK2MSFTNGP10.phx.gbl...
> Try:
>
> Set objClass = new cMyClass
> cMyClass.variable = "Somethign"
>
> if (somecondition) then
> Set objClass=Nothing
> response.redirect("someotherpage.asp")
> end if
>
>
> --
> Mark Schupp
> Head of Development
> Integrity eLearning
> www.ielearning.com
>
>
> "Steve Lutz" <sl***@comcast.net> wrote in message
> news:eF**************@TK2MSFTNGP12.phx.gbl...
> > Hello,
> >
> > I have a page that creates a class, and then on certain
conditions, > > redirects user to another page. The class has a Class_Terminate()
function
> > that saves itself to a database. The class comes from an includes

ASP > file,
> > it isn't a COM object.
> >
> > Here's my code outline (not actual code for brevity - in otherwords, there
> > may be syntax errors, but that's not the cause of the problem)
> >
> > <!--#include file="myclass.asp">
> > <%
> > objClass = new cMyClass
> > cMyClass.variable = "Somethign"
> >
> > if (somecondition) then
> > response.redirect("someotherpage.asp")
> > end if
> >
> > %>
> >
> >
> > The problem I am having is that if the page does not redirect,
cMyClass's
> > Class_Terminate function is run, however, if the redirect
statement is > run,
> > Class_Terminate doesn't get run.
> >
> > Is this a known problem in ASP classic?
> >
> >
>
>



Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by jsWalter | last post: by
1 post views Thread by joseph pattom | last post: by
2 posts views Thread by Gary Brown | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.