/// <summary> /// Displays the 400 Bad Request HTTP status page /// </summary> /// <returns></returns> public async Task <ActionResult> BadRequest() { var templateRequest = new EastSussexGovUKTemplateRequest(Request); var model = new HttpStatusViewModel() { TemplateHtml = await templateRequest.RequestTemplateHtmlAsync() }; return(View(model)); }
/// <summary> /// Responds to a 404 Not Found status by checking for and executing redirects, and displaying the 404 HTTP status page otherwise /// </summary> /// <returns></returns> public async Task <ActionResult> NotFound() { var requestedPath = new NotFoundRequestPathResolver().NormaliseRequestedPath(Request.Url); // Dereference linked data URIs // Linked data has separate URIs for things and documentation about those things. Try to match the URI for a thing and redirect to its documentation. ActionResult redirectResult; if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["SchoolUrl"])) { var schoolUrl = String.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["SchoolUrl"], "$1"); redirectResult = TryUriPattern(requestedPath, "^id/school/([0-9]+)$", schoolUrl, 303, Response.Headers); if (redirectResult != null) { return(redirectResult); } redirectResult = TryUriPattern(requestedPath, "^id/school/([0-9]+)/closure/[0-9]+$", schoolUrl, 303, Response.Headers); if (redirectResult != null) { return(redirectResult); } } // See if it's a short URL for activating a service string guidPattern = "[A-Fa-f0-9]{8,8}-[A-Fa-f0-9]{4,4}-[A-Fa-f0-9]{4,4}-[A-Fa-f0-9]{4,4}-[A-Fa-f0-9]{12,12}"; redirectResult = TryUriPattern(requestedPath, @"^schs\?c=(" + guidPattern + ")$", "https://" + Request.Url.Authority + "/educationandlearning/schools/schoolclosures/closurealertactivate.aspx?code=$1", 303, Response.Headers); if (redirectResult != null) { return(redirectResult); } redirectResult = TryUriPattern(requestedPath, @"^schu\?c=(" + guidPattern + ")$", "https://" + Request.Url.Authority + "/educationandlearning/schools/schoolclosures/closurealertdeactivate.aspx?code=$1", 303, Response.Headers); if (redirectResult != null) { return(redirectResult); } if (TryShortOrMovedUrl(requestedPath)) { // redirect matched and followed - stop processing return(null); } // If no redirects matched, show the 404 page var templateRequest = new EastSussexGovUKTemplateRequest(Request); var model = new HttpStatusViewModel() { TemplateHtml = await templateRequest.RequestTemplateHtmlAsync() }; return(View(model)); }
/// <summary> /// Displays the 500 Internal Server Error HTTP status page /// </summary> /// <returns></returns> public async Task <ActionResult> InternalServerError() { RandomDelay(); var templateRequest = new EastSussexGovUKTemplateRequest(Request); var model = new HttpStatusViewModel() { TemplateHtml = await templateRequest.RequestTemplateHtmlAsync() }; return(View(model)); }