I want to display alert message and redirect to the home page in controller.
The code for Create
action is:
if (ModelState.IsValid)
{
_context.Add(contact);
await _context.SaveChangesAsync();
return Content("<script language='javascript' type='text/javascript'>alert('Thanks for Feedback!');</script>");
}
return View(contact);
But I wanted to use the return RedirectToAction
because it should redirect the user to the specific page in the final execution of code, so how do I replace the return content to redirect to Index
page of HomeController
?