473,325 Members | 2,608 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,325 software developers and data experts.

Retrieve SessionID in Global asax

Does anyone know how to retrieve the current sessionId in
Global.asax.ApplicationError?

/k
Dec 28 '06 #1
11 4718
I am trying to use the SessionID as a key as proposed in:

http://groups.google.se/group/micros...9c79bb10436bec

"kurt sune" <ap*@apa.comwrote in message
news:ef**************@TK2MSFTNGP03.phx.gbl...
Does anyone know how to retrieve the current sessionId in
Global.asax.ApplicationError?

/k


Dec 28 '06 #2
"kurt sune" <ap*@apa.comwrote in message
news:ef**************@TK2MSFTNGP03.phx.gbl...
Does anyone know how to retrieve the current sessionId in
Global.asax.ApplicationError?

/k


Dec 28 '06 #3
"kurt sune" <ap*@apa.comwrote in message
news:ef**************@TK2MSFTNGP03.phx.gbl...
Does anyone know how to retrieve the current sessionId in
Global.asax.ApplicationError?
Er, have you tried:

Session.SessionID
Dec 28 '06 #4
"kurt sune" <ap*@apa.comwrote in message
news:eW*************@TK2MSFTNGP06.phx.gbl...
>I am trying to use the SessionID as a key as proposed in:

http://groups.google.se/group/micros...9c79bb10436bec
You *CANNOT* use SessionID as any sort of unique key, because it is not
guaranteed to be unique in all cases.

See the following from the MSDN Library:
http://msdn2.microsoft.com/en-gb/library/ms524326.aspx
Dec 28 '06 #5
Yepp, it causes {"Session state is not available in this context."}

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:eF**************@TK2MSFTNGP06.phx.gbl...
"kurt sune" <ap*@apa.comwrote in message
news:ef**************@TK2MSFTNGP03.phx.gbl...
Does anyone know how to retrieve the current sessionId in
Global.asax.ApplicationError?

Er, have you tried:

Session.SessionID


Dec 28 '06 #6
Came up with this:

In global.asax:
Dim s As String =
Request.Cookies.Item("ASP.NET_SessionId").Value
If Not s Is Nothing Then Application(s) = "the error text"
Response.Redirect("GenericErrorPage.aspx")

In the error page:

Dim s As String = String.Empty
s = HttpContext.Current.Session.SessionID
Dim ee As String = Application(s).ToString
'display ee on the page

What do you think? A viable solution?

The article you mentioned says that the sessionid is unique between
restarts.

/m
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:Os**************@TK2MSFTNGP03.phx.gbl...
"kurt sune" <ap*@apa.comwrote in message
news:eW*************@TK2MSFTNGP06.phx.gbl...
I am trying to use the SessionID as a key as proposed in:
http://groups.google.se/group/micros...9c79bb10436bec
>
You *CANNOT* use SessionID as any sort of unique key, because it is not
guaranteed to be unique in all cases.

See the following from the MSDN Library:
http://msdn2.microsoft.com/en-gb/library/ms524326.aspx


Dec 28 '06 #7
"kurt sune" <ap*@apa.comwrote in message
news:um**************@TK2MSFTNGP03.phx.gbl...
Yep, it causes {"Session state is not available in this context."}
OK - how about

HttpContext.Current.Session.SessionID
Dec 28 '06 #8
"kurt sune" <ap*@apa.comwrote in message
news:u9**************@TK2MSFTNGP02.phx.gbl...
What do you think? A viable solution?
No.
The article you mentioned says that the sessionid is unique between
restarts.
Er, no it doesn't. Try reading it again - specifically, the bit which says:

"if the Web server is restarted, some SessionID values may be the same as
those generated before the server was stopped."
Dec 28 '06 #9

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
"kurt sune" <ap*@apa.comwrote in message
news:u9**************@TK2MSFTNGP02.phx.gbl...
What do you think? A viable solution?

No.
Why, please?
>
The article you mentioned says that the sessionid is unique between
restarts.

Er, no it doesn't. Try reading it again - specifically, the bit which
says:
>
"if the Web server is restarted, some SessionID values may be the same as
those generated before the server was stopped."
Yes, and when restarted all session and application data gets viped out
and the user has to connect again.

>

Dec 28 '06 #10
"Object reference not set to an instance of an object."

I suspect that global asax is global and instance specific data is thus not
reachable from it.
(they were in VS 2003, but something has changed...)

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:eK**************@TK2MSFTNGP06.phx.gbl...
"kurt sune" <ap*@apa.comwrote in message
news:um**************@TK2MSFTNGP03.phx.gbl...
Yep, it causes {"Session state is not available in this context."}

OK - how about

HttpContext.Current.Session.SessionID


Dec 28 '06 #11
"kurt sune" <ap*@apa.comwrote in message
news:uZ**************@TK2MSFTNGP06.phx.gbl...
>"if the Web server is restarted, some SessionID values may be the same as
those generated before the server was stopped."

Yes, and when restarted all session and application data gets viped out
and the user has to connect again.
And, in doing so, may acquire the SessionID from a different user's session
before the server was restarted i.e. WON'T BE UNIQUE!!!

I really don't know how else to explain this...
Dec 28 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mae | last post by:
Dear all, I'm new to Session.SessionID in Global.asax.vb I wanted to use the sessionID in "Application_AuthenticateRequest" to check for sessionID for each IE, for testing purposes I just put...
2
by: Berrucho | last post by:
Please Help! I recently posted this same issue but got no answer... please help Using VB.NET, IIS5, W2K Adv SP3 all patches, .net 1.0, VS.NET 2002 Using forms authentication, persistent cookie...
8
by: Brad Simon | last post by:
I have written a shopping cart using ASP .NET (VB). It has been running quite successfully on a site for about a year or so. I use the SessionID as the key to hold information on the shopping...
4
by: Andy Fish | last post by:
Hi, I have an asp.net application that is using Forms Authentication and maintaining http session state using cookies in the normal way. when the user clicks the logout button I do this: ...
6
by: Ibrahim. | last post by:
When a new request is made to the server a new session id is issued to the client (a browser instance). The problem I’m facing is that session id that is already assigned to a browser instance...
11
by: Ron | last post by:
I have a web project compiled with the new "Web Deployment Projects" plugin for VS2005. I'm deploying the web project to one assembly and with updateable option set to ON. When I'm running the...
16
by: thefritz_j | last post by:
We just converted our VS2003 1.1 VB web project (which was working fine) to VS2005 2.0 and now I get: Parser Error Message: Could not load type '<Namespace>.'. Source Error: Line 1: <%@...
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.