470,632 Members | 2,554 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Global.asax.cs and Session[]

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.
Dec 12 '07 #1
3 1376
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
JDDoes anybody have any idea why we were able to get Session[] in
JDGlobal.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
JDthis point that Session[] is not available in current context. Why?
JD>
JDJust D.
JD>
Dec 12 '07 #2
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.
Dec 12 '07 #3
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]" <pb*******@yahoo.NoSpamMaam.comwrote in message
news:F9**********************************@microsof t.com...
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.

Dec 12 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by David P. Donahue | last post: by
5 posts views Thread by WJ | last post: by
1 post views Thread by GaryDean | last post: by
12 posts views Thread by =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.