Error.cshtml.cs 714 B

12345678910111213141516171819202122232425262728
  1. using Microsoft.AspNetCore.Mvc;
  2. using Microsoft.AspNetCore.Mvc.RazorPages;
  3. using System.Diagnostics;
  4. namespace WebApplication1.Pages
  5. {
  6. [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
  7. [IgnoreAntiforgeryToken]
  8. public class ErrorModel : PageModel
  9. {
  10. public string? RequestId { get; set; }
  11. public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
  12. private readonly ILogger<ErrorModel> _logger;
  13. public ErrorModel(ILogger<ErrorModel> logger)
  14. {
  15. _logger = logger;
  16. }
  17. public void OnGet()
  18. {
  19. RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
  20. }
  21. }
  22. }