Wednesday, 7 August 2013

How to retrun Errors if UserName Password does not match in MVC 4?

How to retrun Errors if UserName Password does not match in MVC 4?

i am new to MVC, i want to create a simple Login Control. I have write the
below code in controller:
public ActionResult LoginControl(String UserName, String Password)
{
string result = "";
if (UserName == "ram" && Password == "ram123")
{
result = "1";
}
if (result == "1")
{
return View("LoginControl");
}
else
{
return View("Index", "Login");
}
}
Now what i want to do is: if the UserName and password does not match, it
will show me error that "UserName or password does not matched or user
does not exists.", please help me how can i do it.

No comments:

Post a Comment