2023-05-26 19:05:44 +01:00
|
|
|
using System.Diagnostics;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
|
2023-08-04 12:57:35 +01:00
|
|
|
namespace OliverBooth.Pages;
|
2023-05-26 19:05:44 +01:00
|
|
|
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
[IgnoreAntiforgeryToken]
|
|
|
|
public class ErrorModel : PageModel
|
|
|
|
{
|
|
|
|
private readonly ILogger<ErrorModel> _logger;
|
|
|
|
|
|
|
|
public ErrorModel(ILogger<ErrorModel> logger)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2023-08-05 23:27:50 +01:00
|
|
|
public string? RequestId { get; set; }
|
|
|
|
|
|
|
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
|
|
|
|
|
|
|
public int StatusCode { get; private set; }
|
|
|
|
|
|
|
|
public void OnGet(int? code = null)
|
2023-05-26 19:05:44 +01:00
|
|
|
{
|
2023-08-05 23:27:50 +01:00
|
|
|
StatusCode = code ?? HttpContext.Response.StatusCode;
|
2023-05-26 19:05:44 +01:00
|
|
|
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
2023-08-05 23:27:50 +01:00
|
|
|
|
|
|
|
var originalPath = "unknown";
|
|
|
|
if (HttpContext.Items.TryGetValue("originalPath", out object? value))
|
|
|
|
{
|
|
|
|
originalPath = value as string;
|
|
|
|
}
|
2023-05-26 19:05:44 +01:00
|
|
|
}
|
|
|
|
}
|