Monday, March 26, 2012
Session variable is lost between ASP & ASP.NET pages
I must be missing something here. I have an ASP page that I create a
Session variable in as follows.
Session ("name")="Joe"
In an ASP.NET page in the same project and the same session, I call the
Session variable as follows:
Dim str As String
str = Session("name")
When I do a Response.Write (str), nothing writes to the screen.
Any thoughts on what is happening here would be appreciatedUhhhh...
Yeah , that is what it will do. It doesn't work like that.
You can check this out
http://www.asp101.com/articles/sidn...ate/default.asp
but ... the thing surprising you, isn't surprising at all. They are
different technologies...
with nothing but the phrase "asp" in common.
"glenn" <glenn@.discussions.microsoft.com> wrote in message
news:16EE097D-5F1E-4742-AB89-E05057E59EA0@.microsoft.com...
> Hi folks,
> I must be missing something here. I have an ASP page that I create a
> Session variable in as follows.
> Session ("name")="Joe"
> In an ASP.NET page in the same project and the same session, I call the
> Session variable as follows:
> Dim str As String
> str = Session("name")
> When I do a Response.Write (str), nothing writes to the screen.
> Any thoughts on what is happening here would be appreciated
re:
>nothing but the phrase "asp" in common
Absolutely...
The seminal work on sharing session state between ASP and ASP.NET is :
"How to Share Session State Between Classic ASP and ASP.NET"
http://msdn.microsoft.com/library/d...
rttoaspnet.asp
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"sloan" <sloan@.ipass.net> wrote in message news:%23zLsJArUGHA.1160@.TK2MSFTNGP09.phx.gbl...[
color=darkred]
> Uhhhh...
> Yeah , that is what it will do. It doesn't work like that.
> You can check this out
> http://www.asp101.com/articles/sidn...ate/default.asp
> but ... the thing surprising you, isn't surprising at all. They are
> different technologies...with nothing but the phrase "asp" in common.
>
>
> "glenn" <glenn@.discussions.microsoft.com> wrote in message
> news:16EE097D-5F1E-4742-AB89-E05057E59EA0@.microsoft.com...
>[/color]
Session variable is lost between ASP & ASP.NET pages
I must be missing something here. I have an ASP page that I create a
Session variable in as follows.
Session ("name")="Joe"
In an ASP.NET page in the same project and the same session, I call the
Session variable as follows:
Dim str As String
str = Session("name")
When I do a Response.Write (str), nothing writes to the screen.
Any thoughts on what is happening here would be appreciatedUhhhh...
Yeah , that is what it will do. It doesn't work like that.
You can check this out
http://www.asp101.com/articles/sidn...ate/default.asp
but ... the thing surprising you, isn't surprising at all. They are
different technologies...
with nothing but the phrase "asp" in common.
"glenn" <glenn@.discussions.microsoft.com> wrote in message
news:16EE097D-5F1E-4742-AB89-E05057E59EA0@.microsoft.com...
> Hi folks,
> I must be missing something here. I have an ASP page that I create a
> Session variable in as follows.
> Session ("name")="Joe"
> In an ASP.NET page in the same project and the same session, I call the
> Session variable as follows:
> Dim str As String
> str = Session("name")
> When I do a Response.Write (str), nothing writes to the screen.
> Any thoughts on what is happening here would be appreciated
re:
>nothing but the phrase "asp" in common
Absolutely...
The seminal work on sharing session state between ASP and ASP.NET is :
"How to Share Session State Between Classic ASP and ASP.NET"
http://msdn.microsoft.com/library/d...erttoaspnet.asp
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"sloan" <sloan@.ipass.net> wrote in message news:%23zLsJArUGHA.1160@.TK2MSFTNGP09.phx.gbl...
> Uhhhh...
> Yeah , that is what it will do. It doesn't work like that.
> You can check this out
> http://www.asp101.com/articles/sidn...ate/default.asp
> but ... the thing surprising you, isn't surprising at all. They are
> different technologies...with nothing but the phrase "asp" in common.
>
>
> "glenn" <glenn@.discussions.microsoft.com> wrote in message
> news:16EE097D-5F1E-4742-AB89-E05057E59EA0@.microsoft.com...
>> Hi folks,
>>
>> I must be missing something here. I have an ASP page that I create a
>> Session variable in as follows.
>>
>> Session ("name")="Joe"
>>
>> In an ASP.NET page in the same project and the same session, I call the
>> Session variable as follows:
>>
>> Dim str As String
>> str = Session("name")
>>
>> When I do a Response.Write (str), nothing writes to the screen.
>>
>> Any thoughts on what is happening here would be appreciated
Tuesday, March 13, 2012
Session variables dropped using Redirect
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
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?
session variables don't persist ,why?
My problem is that in my login page, I authenticate the user and set a
session variable:
Session("strname") = dr("userlname") & ", " & dr("userfname") & " "
& dr("usermi")
FormsAuthentication.SetAuthCookie(lngID, False)
and then redirect to another page. On that page, when I try:
Response.Write(Session("strname"))
Response.Write(Page.User.Identity.Name)
they're both empty. My web.config includes:
<authentication mode="Forms">
<forms name="P" loginUrl="intranet/login.aspx" protection="All"
path="/" />
</authentication>
The intranet/login.aspx page refers to a page on the server (not part of
this .sln) but I wouldn't think that would matter because it's
authenticating the user in the login page above.
Can anyone help?! Thanks!session refers to current instance of user interaction with an application.
ie if you talk to applicaiton 1 you have one session
if you go to another application like you are (for authentication) its a
different / unique session for that application
since sessions are not shared between applications you dont have any access
to the variables you set earlier.
ie you jumped back to your orignal session which unforntunately dont have
those variables.
Another thing if you try to read session variables it is always advisable to
check them for null values
if not Session("strname") is null then
' read the variables here
end if
something like that..
Regards,
Hermit Dave
(http://hdave.blogspot.com)
"Raed Sawalha" <raed_sawalha@.hotmail.com> wrote in message
news:#TjZprqpEHA.3172@.TK2MSFTNGP10.phx.gbl...
> Hello:
> My problem is that in my login page, I authenticate the user and set a
> session variable:
> Session("strname") = dr("userlname") & ", " & dr("userfname") & "
"
> & dr("usermi")
> FormsAuthentication.SetAuthCookie(lngID, False)
> and then redirect to another page. On that page, when I try:
> Response.Write(Session("strname"))
> Response.Write(Page.User.Identity.Name)
> they're both empty. My web.config includes:
> <authentication mode="Forms">
> <forms name="P" loginUrl="intranet/login.aspx"
protection="All"
> path="/" />
> </authentication>
> The intranet/login.aspx page refers to a page on the server (not part of
> this .sln) but I wouldn't think that would matter because it's
> authenticating the user in the login page above.
> Can anyone help?! Thanks!
>
session variables dont persist ,why?
My problem is that in my login page, I authenticate the user and set a
session variable:
Session("strname") = dr("userlname") & ", " & dr("userfname") & " "
& dr("usermi")
FormsAuthentication.SetAuthCookie(lngID, False)
and then redirect to another page. On that page, when I try:
Response.Write(Session("strname"))
Response.Write(Page.User.Identity.Name)
they're both empty. My web.config includes:
<authentication mode="Forms">
<forms name="P" loginUrl="intranet/login.aspx" protection="All"
path="/" />
</authentication
The intranet/login.aspx page refers to a page on the server (not part of
this .sln) but I wouldn't think that would matter because it's
authenticating the user in the login page above.
Can anyone help?! Thanks!session refers to current instance of user interaction with an application.
ie if you talk to applicaiton 1 you have one session
if you go to another application like you are (for authentication) its a
different / unique session for that application
since sessions are not shared between applications you dont have any access
to the variables you set earlier.
ie you jumped back to your orignal session which unforntunately dont have
those variables.
Another thing if you try to read session variables it is always advisable to
check them for null values
if not Session("strname") is null then
' read the variables here
end if
something like that..
--
Regards,
Hermit Dave
(http://hdave.blogspot.com)
"Raed Sawalha" <raed_sawalha@.hotmail.com> wrote in message
news:#TjZprqpEHA.3172@.TK2MSFTNGP10.phx.gbl...
> Hello:
> My problem is that in my login page, I authenticate the user and set a
> session variable:
> Session("strname") = dr("userlname") & ", " & dr("userfname") & "
"
> & dr("usermi")
> FormsAuthentication.SetAuthCookie(lngID, False)
> and then redirect to another page. On that page, when I try:
> Response.Write(Session("strname"))
> Response.Write(Page.User.Identity.Name)
> they're both empty. My web.config includes:
> <authentication mode="Forms">
> <forms name="P" loginUrl="intranet/login.aspx"
protection="All"
> path="/" />
> </authentication>
> The intranet/login.aspx page refers to a page on the server (not part of
> this .sln) but I wouldn't think that would matter because it's
> authenticating the user in the login page above.
> Can anyone help?! Thanks!