HighTechTalks DotNet Forums  

Global.asax.cs and Session[]

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss Global.asax.cs and Session[] in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Just D
 
Posts: n/a

Default Global.asax.cs and Session[] - 12-11-2007 , 10:33 PM






Does anybody have any idea why we were able to get Session[] in
Global.asax.cs in .NET 1.1 and the same code became unworkable in .NET 2.0?
The code is compilable but the app complains when gets to this point that
Session[] is not available in current context. Why?

Just D.



Reply With Quote
  #2  
Old   
Michael Nemtsev [MVP]
 
Posts: n/a

Default Re: Global.asax.cs and Session[] - 12-12-2007 , 07:49 AM






Hello Just,

Any source code demonstrating this problem? Because as I know there is few
of foretellers

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


JD> Does anybody have any idea why we were able to get Session[] in
JD> Global.asax.cs in .NET 1.1 and the same code became unworkable in
JD> .NET 2.0? The code is compilable but the app complains when gets to
JD> this point that Session[] is not available in current context. Why?
JD>
JD> Just D.
JD>



Reply With Quote
  #3  
Old   
Peter Bromberg [C# MVP]
 
Posts: n/a

Default RE: Global.asax.cs and Session[] - 12-12-2007 , 07:53 AM



You haven't described *where* in global.asax that you are trying to get
Session data, so we can ony guess.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"Just D" wrote:

Quote:
Does anybody have any idea why we were able to get Session[] in
Global.asax.cs in .NET 1.1 and the same code became unworkable in .NET 2.0?
The code is compilable but the app complains when gets to this point that
Session[] is not available in current context. Why?

Just D.




Reply With Quote
  #4  
Old   
Just D
 
Posts: n/a

Default Re: Global.asax.cs and Session[] - 12-12-2007 , 11:04 AM



Peter,

That's easy. I'm not calling Session[] from Application_Start before it was
created for sure. The code I wrote about is located inside protected void
Application_Error(Object sender, EventArgs e) and it was working for several
years with .NET 1.1. After I switched to 2.0 the same code stopped working.
Although the code is compilable it returns a run-time error when I try to
get this:

try
{
//session = (DxSession)Context.Session["Session"];
//session = (DxSession)HttpContext.Current.Session["Session"];
session = (DxSession)Session["Session"];
}
catch
{
return;
}

I also tried these two calls with the same result. I saw these advices on
the Internet.
session = (DxSession)Context.Session["Session"];
session = (DxSession)HttpContext.Current.Session["Session"];

Just D.


"Peter Bromberg [C# MVP]" <pbromberg (AT) yahoo (DOT) NoSpamMaam.com> wrote

Quote:
You haven't described *where* in global.asax that you are trying to get
Session data, so we can ony guess.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"Just D" wrote:

Does anybody have any idea why we were able to get Session[] in
Global.asax.cs in .NET 1.1 and the same code became unworkable in .NET
2.0?
The code is compilable but the app complains when gets to this point that
Session[] is not available in current context. Why?

Just D.






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.