I'm trying to handle errors at aplication level in Genexus Ev1 (C# generator) so when an exception ocurs it can be logged.
Searching the web found the requirement can be resolved with this:
adding a CustomError page at web.config level works fine, but i can't retrieve server's information about the error in the page. Variable &ErrorMsg shown below always return empty
Event Start
&ErrorMsg.SetEmpty()
CSHARP System.Web.HttpServerUtility Server = System.Web.HttpContext.Current.Server;
CSHARP Exception ex = Server.GetLastError();
CSHARP if (ex != null) {
CSHARP ex = ex.GetBaseException();
CSHARP [!&ErrorMsg!] = ex.ToString();
CSHARP }
EndEvent
The code above (and many other variations) doesn't work.
I assume It's ok, because the server exception is being cleared when the error page executing that code is reached so exception is null, then Global.asax file must be configured to catch and transfer the exception
The problem:
On GeneXus web apps there's no global.asax file, so adding it manually executing code below doesn't work either
<%@ language="C#" %>
<script runat="server">
void Application_Error(object sender, EventArgs e){
// Code that runs when an unhandled error occurs.
// Get last error from the server
Exception exc = Server.GetLastError();
if (exc is HttpUnhandledException){
if (exc.InnerException != null){
exc = new Exception(exc.InnerException.Message);
Server.Transfer("ErrorPageLog.aspx?handler=Application_Error%20-%20Global.asax",
true);
}
}
}
Theres anyone who have tried to do this in GeneXus already? Anyone can clarify what I'm doing wrong?