Showing posts with label redirect. Show all posts
Showing posts with label redirect. Show all posts

Saturday, March 31, 2012

session timeout.... again

Hi Everyone -

This session timeout thing has popped up again.

Is there a way to globally redirect the user to a timeout
page when the session variables have timed out?

I really don't want to add a check on each and every page
in the page_load that will check the session.

please advise...

I've tried to check the session variable in the global.asax
file in the

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires at the beginning of each request
if session.Item("company_id") is nothing then
response.Redirect("logout.aspx")
End If
End Sub

but the session object is not allowed in this context

any ideas would be appreciated

thanks
tonyAn alternate method will be create a small function in one of the module and then just call the function at the top of each page.

Function Is_Session_Alive will return Flase is session has lost its values otherwise True

At the start of each page
If Is_Session_Alive(Session("Language"), Session("Service"), Session("Department")) = False Then
Response.Redirect("DefaultErrorPage.aspx")
End If

Thanks
Shafiq
make a class inheriting the page and code there.

subsiquently inherit new class on every page

hemant

Tuesday, March 13, 2012

Session variables dropped using Redirect

I cannot get a session to stay active between web pages. I initialize a
Session with variables and then execute a Response.Redirect(url,false); The
called web page has a different sessionid that the page which sent the
response. I have my sessionstate set to:
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false" timeout="20"/>
and both webpages are in the same application. My system was working for
over 2 years and now all of a sudden it drops a session whenever I go from
one webpage to another. Does anyone have a clue as to what to check for
next?Session is based on cookies sent by the browser
so if you are redirecting from www.mydomain.com to mudomain.com, to
ASP.NET that's two separate sites even though it's on the same machine and
the same IIS Application. But it could be a lot of other things too,
application restarts, etc. You could get Fiddler and scope around in the
requests, that might give you a clue by examining the headers.
The other thing to think about is "what has changed on my machine recently".
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Parrot" wrote:

> I cannot get a session to stay active between web pages. I initialize a
> Session with variables and then execute a Response.Redirect(url,false); T
he
> called web page has a different sessionid that the page which sent the
> response. I have my sessionstate set to:
> <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
> sqlConnectionString="data source=127.0.0.1;user id=sa;password="
> cookieless="false" timeout="20"/>
> and both webpages are in the same application. My system was working for
> over 2 years and now all of a sudden it drops a session whenever I go from
> one webpage to another. Does anyone have a clue as to what to check for
> next?
>
Peter;
Thanks for your reply. I have checked everything out that I can think of.
It happens using both IE and Firefox so its not the browser. Cookies are
turned on and I have not made any changes to IIS. The system works on my IS
P
but not on my machine which is a clue but I don't know what to check next.
It really is frustrating and I am thinking of passing data in querystrings
but I can't figure out how to encrypt the data since it is secure data.
What is Fiddler?
"Peter Bromberg [C# MVP]" wrote:
> Session is based on cookies sent by the browser
> so if you are redirecting from www.mydomain.com to mudomain.com, to
> ASP.NET that's two separate sites even though it's on the same machine and
> the same IIS Application. But it could be a lot of other things too,
> application restarts, etc. You could get Fiddler and scope around in the
> requests, that might give you a clue by examining the headers.
> The other thing to think about is "what has changed on my machine recently
".
> Peter
>
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Parrot" wrote:
>

Session variables dropped using Redirect

I cannot get a session to stay active between web pages. I initialize a
Session with variables and then execute a Response.Redirect(url,false); The
called web page has a different sessionid that the page which sent the
response. I have my sessionstate set to:

<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false" timeout="20"/>

and both webpages are in the same application. My system was working for
over 2 years and now all of a sudden it drops a session whenever I go from
one webpage to another. Does anyone have a clue as to what to check for
next?Session is based on cookies sent by the browser

so if you are redirecting from www.mydomain.com to mudomain.com, to
ASP.NET that's two separate sites even though it's on the same machine and
the same IIS Application. But it could be a lot of other things too,
application restarts, etc. You could get Fiddler and scope around in the
requests, that might give you a clue by examining the headers.

The other thing to think about is "what has changed on my machine recently".
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Parrot" wrote:

Quote:

Originally Posted by

I cannot get a session to stay active between web pages. I initialize a
Session with variables and then execute a Response.Redirect(url,false); The
called web page has a different sessionid that the page which sent the
response. I have my sessionstate set to:
>
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false" timeout="20"/>
>
and both webpages are in the same application. My system was working for
over 2 years and now all of a sudden it drops a session whenever I go from
one webpage to another. Does anyone have a clue as to what to check for
next?
>
>


Peter;
Thanks for your reply. I have checked everything out that I can think of.
It happens using both IE and Firefox so its not the browser. Cookies are
turned on and I have not made any changes to IIS. The system works on my ISP
but not on my machine which is a clue but I don't know what to check next.
It really is frustrating and I am thinking of passing data in querystrings
but I can't figure out how to encrypt the data since it is secure data.
What is Fiddler?

"Peter Bromberg [C# MVP]" wrote:

Quote:

Originally Posted by

Session is based on cookies sent by the browser
>
so if you are redirecting from www.mydomain.com to mudomain.com, to
ASP.NET that's two separate sites even though it's on the same machine and
the same IIS Application. But it could be a lot of other things too,
application restarts, etc. You could get Fiddler and scope around in the
requests, that might give you a clue by examining the headers.
>
The other thing to think about is "what has changed on my machine recently".
Peter
>
>
>
>
>
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
>
>
>
>
"Parrot" wrote:
>

Quote:

Originally Posted by

I cannot get a session to stay active between web pages. I initialize a
Session with variables and then execute a Response.Redirect(url,false); The
called web page has a different sessionid that the page which sent the
response. I have my sessionstate set to:

<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false" timeout="20"/>

and both webpages are in the same application. My system was working for
over 2 years and now all of a sudden it drops a session whenever I go from
one webpage to another. Does anyone have a clue as to what to check for
next?