Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:45:42+00:00 2026-05-22T20:45:42+00:00

I’m thinking of adding some code to my global.asax to my web apps to

  • 0

I’m thinking of adding some code to my global.asax to my web apps to email me when there is an unhandled exception.

Current, I’m doing the following

  • Writing a cookie on the user’s machine – in case they spam hit F5 and the website was restarted
  • Adding an entry into system.Web.Cache –

Am I missing something? Would you do something different?

protected void Application_Error()
{
    var ex = Server.GetLastError();
    Server.ClearError();

    if (NotInCache(ex))
    {
        // Email support
    }
}



private static bool NotInCache(Exception ex)
{
    bool returnValue = true;

        if (ex != null)
        {
            HttpContext current = HttpContext.Current;
            LogWriter.Trace(MethodBase.GetCurrentMethod(), Dfait.Diagnostics.TraceLevel.Level4, "Checking Cache for our exception");

            if (current != null)
            {
                string key = ex.StackTrace;
                string[] split = System.Text.RegularExpressions.Regex.Split(ex.StackTrace, "\r\n");
                string value = "Exception Exists";
                DateTime expiryDate = DateTime.Now.AddDays(1);

                if (split.Length > 0)
                {
                    key = split[0];
                }

                key = key.Trim();

                HttpCookie remedyCookie = current.Request.Cookies[key];

                if (remedyCookie == null)
                {
                    HttpCookie newCookie = new HttpCookie(key, value);
                    newCookie.Expires = expiryDate;
                    current.Response.Cookies.Add(newCookie);
                }
                else
                {
                    returnValue = false;
                }

                // The next block is to check the cache of the user.
                object foundCache = HttpRuntime.Cache[key];

                if (foundCache == null)
                {
                    HttpRuntime.Cache.Insert(key, value, null, expiryDate, TimeSpan.Zero);
                }
                else
                {
                    returnValue = false;
                }
            }
        }

    return returnValue;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:45:42+00:00Added an answer on May 22, 2026 at 8:45 pm

    Depending on how soon you want the exceptions you could always just log them to a file and then email the file to yourself every 10 minutes, 1 hour, 1 day and etc.

    That way you don’t need to worry to much about if people spam the website as it will just be a bunch of duplicate exceptions in the file.

    Once you send the file you could delete it or some how mark it as sent and then start a new file that way you only get a file emailed once there is something new to be sent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.