public IActionResult SubmitFeedback([FromForm(Name = "url-referer")] string urlReferer) { PageVM pageViewModel = null; try { pageViewModel = GetPage(); if (pageViewModel == null) { return(GetCustomErrorCode(EnumStatusCode.RPSubmissionJsonError, "Error submitting service feedback. Json form not loaded")); } urlReferer = _gdsValidate.CleanText(urlReferer, true, _restrictedWords, _allowedChars); if (urlReferer.IsEmpty()) { urlReferer = _configuration.GetSection("ApplicationSettings:GFCUrls").GetValue <string>("StartPage"); } _gdsValidate.ValidatePage(pageViewModel, Request.Form, true, _restrictedWords, _allowedChars); if (pageViewModel.Questions.Any(m => m.Validation?.IsErrored == true)) { var cleanUrlReferer = urlReferer.Replace("feedback-thank-you", ""); ViewBag.BackLink = new BackLinkVM { Show = true, Url = cleanUrlReferer, Text = _configuration.GetSection("ApplicationSettings:SiteTextStrings").GetValue <string>("BackLinkText") }; ViewBag.UrlReferer = cleanUrlReferer; ViewBag.HideHelpLink = true; ViewBag.Title = "Error: Report a problem" + _configuration.GetSection("ApplicationSettings:SiteTextStrings").GetValue <string>("SiteTitleSuffix"); return(View(nameof(Feedback), pageViewModel)); } var emailAddress = pageViewModel? .Questions?.FirstOrDefault(x => x.QuestionId.Equals("email-address"))? .Answer ?? string.Empty; //record this action var sessionId = _sessionService.GetSessionId(); var action = GetUserAction(pageViewModel, sessionId); _actionService.CreateAsync(action); Task.Run(async() => { await SendEmailNotificationAsync(pageViewModel, urlReferer, emailAddress) .ContinueWith(notificationTask => { if (notificationTask.IsFaulted) { _logger.LogError(notificationTask.Exception, "Error sending service feedback email."); } }) .ConfigureAwait(false); }); return(RedirectToAction(nameof(FeedbackThankYou), new { urlReferer })); } catch (Exception ex) { ex.Data.Add("GFCError", "Unexpected error submitting service feedback"); throw ex; } }