G
Guest
This is what i am trying to do
I have a DAL that contains all of my database connections/reads etc.
I have a separate GUI layer that has my web pages
I would like to pass my exception errors in my DAL to a custom web page to
display to the user.
Here is what I have done so far
1. Created a CustomError web page that displays the error to the user in a
friendly format
2. Modified my Global.asax file to caputre the error and put it in a
Session variable.
3. Modified my Web.Config file to on error redirect my user to a custom
error page.
Problem - my error page comes up but there is no message being returned
Here is the code that I am using:
An example DAL code block throwing the exception
Public Function GetAllLevel1(ByVal ds As DataSet)
Dim myConnection As New
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PMADataAccess"))
Dim myCommand As New SqlDataAdapter("sp_SelectAllLevel1",
myConnection)
Try
myCommand.Fill(ds, "AllLevel1")
Catch ex As Exception
Throw New System.Exception(ex.Message.ToString)
End Try
myConnection.Close()
Return ds
End Function
In Global.asax
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim LastError As Exception
LastError = Server.GetLastError()
Session("CurrentError") = LastError.Message
End Sub
In my Web.config file
<customErrors mode="On" defaultRedirect="GUI\ErrorPage.aspx"/>
In my ErrorPage.aspx.vb file
lblErrorDetails.Text = Session("CurrentError")
Now I am pretty sure that my problem has to do with context for the session,
but for the love of me I cannot figure out how to fix it. Also it seems that
the error message i am getting when i debug the Application_error routine is
a generic error message and not the system.exception message i am expecting
(example - I get the message (an unhandled exception has occured) instead of
the message (Login failed for PMAUser) when i debug the value
ex.Message.ToString in my DAL code. Why is this happening?
If anyone knows of where I can find an example of how to do what I am doing
or if you know how I can fix my Session problem I would much appreciate it.
Corey
I have a DAL that contains all of my database connections/reads etc.
I have a separate GUI layer that has my web pages
I would like to pass my exception errors in my DAL to a custom web page to
display to the user.
Here is what I have done so far
1. Created a CustomError web page that displays the error to the user in a
friendly format
2. Modified my Global.asax file to caputre the error and put it in a
Session variable.
3. Modified my Web.Config file to on error redirect my user to a custom
error page.
Problem - my error page comes up but there is no message being returned
Here is the code that I am using:
An example DAL code block throwing the exception
Public Function GetAllLevel1(ByVal ds As DataSet)
Dim myConnection As New
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PMADataAccess"))
Dim myCommand As New SqlDataAdapter("sp_SelectAllLevel1",
myConnection)
Try
myCommand.Fill(ds, "AllLevel1")
Catch ex As Exception
Throw New System.Exception(ex.Message.ToString)
End Try
myConnection.Close()
Return ds
End Function
In Global.asax
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim LastError As Exception
LastError = Server.GetLastError()
Session("CurrentError") = LastError.Message
End Sub
In my Web.config file
<customErrors mode="On" defaultRedirect="GUI\ErrorPage.aspx"/>
In my ErrorPage.aspx.vb file
lblErrorDetails.Text = Session("CurrentError")
Now I am pretty sure that my problem has to do with context for the session,
but for the love of me I cannot figure out how to fix it. Also it seems that
the error message i am getting when i debug the Application_error routine is
a generic error message and not the system.exception message i am expecting
(example - I get the message (an unhandled exception has occured) instead of
the message (Login failed for PMAUser) when i debug the value
ex.Message.ToString in my DAL code. Why is this happening?
If anyone knows of where I can find an example of how to do what I am doing
or if you know how I can fix my Session problem I would much appreciate it.
Corey