473,396 Members | 1,918 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,396 software developers and data experts.

global.asax : Application_Error and Session don't work

In my ASP.NET 2.0 application I have in the global.asax.file the following
code

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
This dousn't work !!! Get error "Session state is not available in this
context."
Dim ex As Exception
ex = Server.GetLastError.InnerException
Session("Exception") = ex
Session("FilePath") = Server.MapPath(Me.ToString)
Response.Redirect("ErrorPage.aspx")
End Sub

I've get the error "Session state is not available in this context." when
there's an error on a page ...

Thanks for any help on this ...

Benny
Jun 3 '07 #1
4 14458
"BenCoo" <te******@hotmail.comwrote in message
news:xm**********************@phobos.telenet-ops.be...
Thanks for any help on this ...
Google is your friend:
http://www.google.co.uk/search?sourc...his+context%22
--
http://www.markrae.net

Jun 3 '07 #2
Thanks, but didn't find a solution while the aspx-page where this error is
generated is in a subdirectory
"Mark Rae" <ma**@markNOSPAMrae.netschreef in bericht
news:un**************@TK2MSFTNGP04.phx.gbl...
"BenCoo" <te******@hotmail.comwrote in message
news:xm**********************@phobos.telenet-ops.be...
>Thanks for any help on this ...

Google is your friend:
http://www.google.co.uk/search?sourc...his+context%22
--
http://www.markrae.net

Jun 3 '07 #3
Are you using code-behind ?

If so, you need to use HttpContext.Current
..

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"BenCoo" <te******@hotmail.comwrote in message
news:xm**********************@phobos.telenet-ops.be...
In my ASP.NET 2.0 application I have in the global.asax.file the following code

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
This dousn't work !!! Get error "Session state is not available in this context."
Dim ex As Exception
ex = Server.GetLastError.InnerException
Session("Exception") = ex
Session("FilePath") = Server.MapPath(Me.ToString)
Response.Redirect("ErrorPage.aspx")
End Sub

I've get the error "Session state is not available in this context." when there's an error on a
page ...

Thanks for any help on this ...

Benny


Jun 3 '07 #4
Also, check out this blog :

http://blogs.gotdotnet.com/mattwag/a...07/368605.aspx

There's a workaround there, by Baryon, which uses an Application variable,
and another workaround, by Naimish R. Dave, which lets you use Session variables.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uN**************@TK2MSFTNGP05.phx.gbl...
Are you using code-behind ?

If so, you need to use HttpContext.Current
.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"BenCoo" <te******@hotmail.comwrote in message
news:xm**********************@phobos.telenet-ops.be...
>In my ASP.NET 2.0 application I have in the global.asax.file the following code

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
This dousn't work !!! Get error "Session state is not available in this context."
Dim ex As Exception
ex = Server.GetLastError.InnerException
Session("Exception") = ex
Session("FilePath") = Server.MapPath(Me.ToString)
Response.Redirect("ErrorPage.aspx")
End Sub

I've get the error "Session state is not available in this context." when there's an error on a
page ...

Thanks for any help on this ...

Benny



Jun 3 '07 #5

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

Similar topics

1
by: Greg Burns | last post by:
I am trying to write a global custom error page. I thought I would jot down some of what I've learned so far... At first I just used the default customErrors section with a defaultRedirect tag,...
3
by: Mike Malter | last post by:
I have a general error page that I configured in web.config as <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" /> This error page comes up whenever an error occurs outside of any...
2
by: Alex Maghen | last post by:
It looks as if user imporsonation doesn't work in the Global.asax OnStart event. What this means is that if I have application configured to use "AlexUser" as the user for all ASP.NET stuff, that...
5
by: vbMental | last post by:
I am deep into a project and cannot get this to work correctly. I am trying to make a custom error page that will be able to know what exception occurred. I already know about the defaultRedirect...
4
by: Ron Weldy | last post by:
I'm trying to get asp.net errors to write a entry in the server Application log and have created an global.asax file and placed it in the root folder where my web files reside but when I trigger an...
2
by: tshad | last post by:
I have my error handling set up in Global.asax: Sub Application_Error(Sender As Object, E as EventArgs) In this procedure I call a function in a dll that will write out to a history file. ...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
4
by: oliv | last post by:
I need some global app strong typed variable. So in my solution explorer, I did: Add New Item | Global Application class It add me a file Global.asax : <%@ Application Language="C#" %> ...
1
by: daonho | last post by:
Hi Everyone, I have encountered this problem that I am not able to figure out. Please drop me some lines if you have any idea how to solve this issue. I have a global.asax file in my web site. It...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.