Standard Application_Error code for Global.asax RRS feed

  • Question

  • User-2053865247 posted


    my code for the Application_Error area of Global.asax is pretty messy for my public website.  Things that I've had to write code for:

    1.  Search engine bots that make invalid requests

    2.  Random web crawling tools by ZmEu and other malicious bots out there

    Would anyone be willing to share their code for Application_Error that is a best practice and handles the above?



    Wednesday, January 2, 2013 11:30 AM


  • User71929859 posted


    You can check the request in your Application_Error method like below

    if ((Request.Url.ToString().Contains("malcious_content_here")))
        //Invalid request

    Replace malcious_content_here with whatever text you are going to identify the invalid request.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 5, 2013 12:38 AM