I build a C# ASP.NET Core 2 MVC app and this is working fine. Sometimes I got some strange errors in my database and I need more data to analyze.
I have my own error-class
if (env.IsProduction())
{
app.UseBrowserLink();
app.UseExceptionHandler("/error/index");
}
And log already more data - like IP address or userid if user is logged in:
_context.Error.Add(new Error
{
errorMessage = feature.Error.Message?.ToString(),
errorStackTrace = feature.Error.StackTrace?.ToString(),
errorUserAgent = Request.Headers["User-Agent"].ToString(),
errordate = DateTime.Now,
errorIP = HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress?.ToString(),
errorInnerException = feature.Error.InnerException?.ToString(),
errorSource = feature.Error.Source?.ToString(),
errorUserID = (tmpUserID.ToString() == "00000000-0000-0000-0000-000000000000") ? null : tmpUserID.ToString(),
errorForm = SesionFormData
});
_context.SaveChanges();
But I found no way to get session-data or even simple URL-parameter of the request who crashed :(
Is there a way?
Thanks a lot Ralf