473,386 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1461
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: David P. Donahue | last post by:
When I wrote websites in VB .NET, I would often put functions in Global for all the pages to call. Now, in C#, doing so results in "references to non-static objects" and whatnot. I realize what...
5
by: WJ | last post by:
I am attempting to use the Global.Asax to store my user's configuration. Here is the concept: 1. User logs on into the site using Form Authentication. 2. I capture the user Credential, verify it...
1
by: GaryDean | last post by:
I notice that the global.asax in v2 is inline. because of this I can't say Session = conn; The compiler will accept it but at runtime the exception says "Session State is not available in this...
3
by: kurt sune | last post by:
I have a generic errorhandler in global.asax. (in Application_Error) I need to transfer an error string from global asax to a generic error page. So I try: this code with the thought of...
12
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I am trying to maintain a list of people who are currently "online" in SQL. I do this by adding a simple entry to a simple PeopleOnline table whenever someone logs in to my site. If they...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.