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 7763031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:33:44+00:00 2026-06-01T14:33:44+00:00

When users are entering information on my site and experience an exception, what is

  • 0

When users are entering information on my site and experience an exception, what is the best way to capture that exception. I would like to know what were they filling out on the form when the exception occurred. How have you handled it? what tool have you used? I have looked into ELMAH and log4net and currently trying to use log4net to capture this information. Any suggestions on what is the best way to capture form fields?

  • 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-06-01T14:33:46+00:00Added an answer on June 1, 2026 at 2:33 pm

    In your Application_Error in Global.asax.cs, you can access the following and log them. This is what we do (with our specifics removed).

    Obviously in place of each var whatever = ..., you would do LogInSomeWay(whatever). This code just demonstrates assigning each important piece of the current experience to a variable.

    Hope this helps.

    Code

    void Application_Error(object sender, EventArgs e)
    {
        Exception ex = Server.GetLastError();
        HttpContext context = HttpContext.Current;
    
        bool requestAvailable = false;
        try
        {
            if (context.Request != null)
            {
                requestAvailable = true;
            }
        }
        catch{}
    
        if (context != null) var serverName = context.Server.MachineName;
    
        if (context != null && requestAvailable)
        {
            var referrer = context.Request.UrlReferrer != null ? context.Request.UrlReferrer.ToString() : "";
    
            // If you use forms authentication and define your own principal, do some logging with it here
            OurPrincipal user = OurContext.Current.LoggedOnPrincipal;
            if (user != null && user.Identity != null && user.Identity.IsAuthenticated && user.Person != null)
            {
                var logonName = user.Person.LogonName;
                var loginPersonName = user.Person.FirstName + " " + user.Person.LastName;
            }
    
            var userIP = context.Request.UserHostAddress;
            var userDns = context.Request.UserHostName;
            var userAgent = context.Request.UserAgent;
            var exceptionText = ex.ToString();
    
            foreach (string key in context.Request.ServerVariables.AllKeys)
            {
                var currentServerVarKey = key;
                var currentServerVarValue = context.Request.ServerVariables[key];
            }
    
            if (context.Request.ServerVariables["REQUEST_METHOD"] == "POST"
                && context.Request.Form != null && context.Request.Form.AllKeys != null)
            {
                foreach (string key in context.Request.Form.AllKeys)
                {
                    var currentFormKey = key;
                    var currentFormValue = context.Request.Form[key];
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to setup a RegularExpressionValidator to ensure users are entering valid windows IDs
I have a CMS running. I am seeing that my CMS users are entering
I have a search page where I would like to stop the user entering
We have business users who are entering product information into excel spreadsheets. I have
What is the best way to pass information from an activity one to a
I'm a total newbie to Facebook programming and would like to know, as a
I'm creating an iPhone application that requires a user entering information into a form,
I've implemented markitup to handle users entering markdown text. I want to replace the
How can I restrict users from entering special characters in the text box. I
For example, the users of our app want to search products by entering a

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.