?
Solved

application error in global.asax

Posted on 2007-10-17
6
Medium Priority
?
442 Views
Last Modified: 2008-01-09
In AS{.NET 2.0 with C# I  have an errorpage and in global.asax I added to Application_Error to print the error in an errorpage I defined.
I have some problems:
first I have to run the application in the mode without debugging otherwise it get to the application error all the time.
second if I run without the debugging not all the errors are catched.
How does tthis function work?
0
Comment
Question by:ANAT2403
  • 3
  • 2
6 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 1000 total points
ID: 20093171
Your best bet is to just Response.Redirect to the error page and display the information on that page rather than through the global.asax.

void Application_Error(object sender, EventArgs e)
{
    System.Web.HttpContext.Current.Response.Redirect("Error.aspx");
}

if you need to retain error information, then store it to a session variable and read it in on the PageLoad of Error.aspx.
0
 
LVL 7

Expert Comment

by:nisarkhan
ID: 20093550
 void Application_Error(object sender, EventArgs e)
    {
        try
        {
            Server.Transfer("~/ExceptionPage.aspx", false);
        }
        catch { ;}
    }

and in exceptionpage.aspx.cs page_load

 if (ex != null)
{
    //
}
0
 

Author Comment

by:ANAT2403
ID: 20094485
Hi nisarkhan,
What do you mean by
if (ex != null)
{
    //
}
where ex comes from?
Anat
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Assisted Solution

by:nisarkhan
nisarkhan earned 1000 total points
ID: 20096372
opps i forgot the fist line

here is what i mean:
void Application_Error(object sender, EventArgs e)
    {
        try
        {
            GetErrors(Context.Error.GetBaseException(), string.Empty, string.Empty, string.Empty);
            Server.Transfer("~/ExceptionPage.aspx", false);
        }
        catch { ;}
    }

and in exceptionpage.aspx.cs page_load

 if (ex != null)
{
    //
}
 
0
 

Author Comment

by:ANAT2403
ID: 20101928
Hi,
What is the difference and what is prefered between
System.Web.HttpContext.Current.Response.Redirect("ErrorPage.aspx");
and
Server.Transfer("~/ErrorPage.aspx", true);
Thankyou
Anat
0
 
LVL 7

Expert Comment

by:nisarkhan
ID: 20101952
the diff is response.rediect vs server.transfer

http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=15
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question