Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Global.asax.cs and Session[]

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Just D - 12 Dec 2007 03:33 GMT
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.
Michael Nemtsev [MVP] - 12 Dec 2007 12:49 GMT
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>
Peter Bromberg [C# MVP] - 12 Dec 2007 12:53 GMT
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 

> 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.
Just D - 12 Dec 2007 16:04 GMT
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.

> You haven't described *where* in global.asax that you are trying to get
> Session data, so we can ony guess.
[quoted text clipped - 10 lines]
>>
>> Just D.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.