2018-05-22 10:11:50 +02:00
|
|
|
using System.Diagnostics;
|
|
|
|
using Microsoft.AspNetCore.Diagnostics;
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
namespace Monitor.Pages
|
|
|
|
{
|
|
|
|
public class ErrorModel : PageModel
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
public string RequestId { get; set; }
|
2019-11-15 04:18:43 +01:00
|
|
|
public IExceptionHandlerFeature Exception = null;
|
2018-05-22 10:11:50 +02:00
|
|
|
|
|
|
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
public void OnGet()
|
|
|
|
{
|
2019-11-15 04:18:43 +01:00
|
|
|
Exception = HttpContext.Features.Get<IExceptionHandlerFeature>();
|
|
|
|
|
2019-11-13 00:17:02 +01:00
|
|
|
var exceptionFeature = HttpContext.Features.Get<IExceptionHandlerPathFeature>();
|
2018-05-22 10:11:50 +02:00
|
|
|
|
|
|
|
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
2019-11-13 00:17:02 +01:00
|
|
|
|
2019-11-16 02:19:02 +01:00
|
|
|
string errorString = exceptionFeature.Error.ToString();
|
|
|
|
if (!errorString.Contains("is being used")) {
|
|
|
|
Logger.WriteException(exceptionFeature.Error, "An error occurred whilst requesting " + exceptionFeature.Path);
|
|
|
|
}
|
2018-05-22 10:11:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|