Hello In my project I have to pass a welcome message with username to the Index Page Its a MVC3 ASP.Net Razor project
There are two controllers are there; O
Change the Index() method of Home Controller to this:
[HttpPost]
public ActionResult Index(string username)
{
ViewBag.user=username;
return View();
}
Modify the Login Controller :
if (DataAccess.DAL.UserIsValid(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, false);
return RedirectToAction("Index", "Home",new { username = model.Username } );
//sending the parameter 'username'value to Index of Home Controller
}
Go to the View Page of the Index method of Home Controller and add the following:
User is: @ViewBag.user
And you're done. :)