The following code redirects to a view with the anchor and works. However I need to send the model state through for validation and I am not sure how to do that while using a redirect. I want to set the model error to populate the validation summary.
[HttpPost]
public ActionResult Send(QuoteModel model, string CatchAll)
{
try
{
if (ModelState.IsValid)
{
}
else
{
ModelState.AddModelError(string.Empty, "There is something wrong with Foo.");
return Redirect(Url.RouteUrl(new { controller = "Home", action = "Index"}) + "#quote");
}
}
catch
{
return View();
}
}
I think you can’t do it this way, try to add an additional parameter for your action to determine if the error occurs
and check this url parameter in your action.