I am having a AccountController
in which I have an action YNHHConsentForm
inside this action I am redirecting to another View using RedirectToAction("Index", "Default")
. Now I want to show a message on Index page of Default. I have tried to pass value using ViewBag
or ViewData
but it remains null
and I am unable to use its value on Index.
AccountController
public ActionResult YNHHConsentForm(YNHHFormVM model)
{
if (result == 0 || isSuccess == false)
{
model.FormSubmissionMessage = "Something went wrong please try again";
return View(model);
}
else
{
SessionItems.IsAuthorizationFormFilled = true;
//ViewBag.FormSubmissionMessage="Form submitted successfully";
ViewData["FormSubmissionMessage"] = "Form submitted successfully";
return RedirectToAction("Index", "Default");
}
}
Index(Default)
@if (ViewData["FormSubmissionMessage"] !=null)
{
<div class="alert alert-success">
ViewData["FormSubmissionMessage"].ToString()
</div>
}
I am using ViewBag
and ViewData
for first time so not able to figure out where I am doing wrong.