Redirecting from a class

R

Ryan Ternier

The software project I'm running uses a lot of helper classes.

I have the habbit of catching errors in any place they occur, but I'm
having troubles with one particular spot.

I didn't code this project to automatically regenerate Sessions when the
website updates. So when the website updates (new DLL, web.config edited
etc.) the sessions are lost, and the users are kicked.

The error is always caught inside my User class (which defines
everything about the logged in user).

When an error occurs in this class, I tried to do:

dim objUtil as new Utility(Utility inherits Page)
objUtil.Redirect("some_page_here.aspx")

But this errors and tells me I cannot redirect like this.

Is there a way of having a flag set inside that class which calls a
function on the calling page allowing it to redirect to the login page
so they can log in again.. and not get an error page telling them to log
in again...


/RT
 
G

Guest

Ryan,

Better yet, why don't you make sure than when you add a new DLL the sessions
are still there by saving them all the time on an SQL database. Read about
SQL Session managment, you'll find the answer there, you are using InProc now
that's why you are losing the Session every time.

Cheers
Al
 
R

Ryan Ternier

Al, Thanks for the reply.

We've done that on the new projects. I don't have the resources to
spend that effort on this project. Which is why i'm seeing if this is
viable.

However, regardless on what causes the error, is there a way to set an
event, or flag in a class, that when set, automatically invokes the
calling page to do something?

/RT
 
R

Ryan Ternier

Al, Thanks for the reply.

We've done that on the new projects. I don't have the resources to
spend that effort on this project. Which is why i'm seeing if this is
viable.

However, regardless on what causes the error, is there a way to set an
event, or flag in a class, that when set, automatically invokes the
calling page to do something?

/RT
 
G

Guest

Ryan,

What I would do is to right some code on the Global.asax function:
protected void Session_End(Object sender, EventArgs e)
{
Response.Redirect("Login.aspx");
}

Otherwise you can create a user control to check for Session.IsAthenticated
and if false redirect it, however you'll have to add this user control in all
pages.

Hope this helps
Al
 
G

Guest

Since Response is a member of Page class, You can use

objUtil.Response.Redirect("some_page_here.aspx")


HTH

Elton Wang
(e-mail address removed)
 
M

Mythran

Ryan Ternier said:
The software project I'm running uses a lot of helper classes.

I have the habbit of catching errors in any place they occur, but I'm
having troubles with one particular spot.

I didn't code this project to automatically regenerate Sessions when the
website updates. So when the website updates (new DLL, web.config edited
etc.) the sessions are lost, and the users are kicked.

The error is always caught inside my User class (which defines everything
about the logged in user).

When an error occurs in this class, I tried to do:

dim objUtil as new Utility(Utility inherits Page)
objUtil.Redirect("some_page_here.aspx")

But this errors and tells me I cannot redirect like this.

Is there a way of having a flag set inside that class which calls a
function on the calling page allowing it to redirect to the login page so
they can log in again.. and not get an error page telling them to log in
again...


/RT

How about HttpContext.Current.Response.Redirect("Page.aspx")?

Mythran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top