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; One is Login Controller and the second one is Home Controller. From Login Controller, I have to pass UserName of the Login Person to the view Page.
Login Controller redirect to Another controller called Home Controller .From there I have to pass that value to the view page. That's my issue. I have tried with single controller to view, its working.
I cant use the single controller because Login Controller uses Login Page and Home Controller uses Home Page. Both are separate views.
I have tried Like this, but its not working. Can you suggest a good Method to follow?
Login Controller
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(LoginModel model)
{
if (ModelState.IsValid)
{
if (DataAccess.DAL.UserIsValid(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, false);
return RedirectToAction("Index", "Home" );
}
else
{
ModelState.AddModelError("", "Invalid Username or Password");
}
}
return View();
}
Home Controller
public ActionResult Index()
{
return View();
}