namespace CSR.WebUI.Pages; using Microsoft.AspNetCore.Mvc.RazorPages; using System.Web; public class AccessDeniedModel : PageModel { public string ResourceName { get; set; } = "the requested resource"; // Default message public void OnGet(string returnUrl) { if (!string.IsNullOrEmpty(returnUrl)) { // Decode the URL if it was encoded var decodedUrl = HttpUtility.UrlDecode(returnUrl); var uri = new Uri("http://localhost" + decodedUrl); // Use a base URI to help with parsing ResourceName = uri.Segments.Length > 1 ? uri.Segments.Last() : "the requested resource"; if (string.IsNullOrEmpty(ResourceName)) { ResourceName = "the requested resource"; } } } }