I am having my login model.
public class Login
{
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string password { get; set; }
[Required(ErrorMessage = "Enter User name")]
public string username { get; set; }
}
when i am geting value from view to controler in thisway
Login t = new Login();
t.password = fr["password"];
t.username = fr["username"];
but error is coming...
password The name 'password' does not exist in the current context
username The name 'password' does not exist in the current context
What I have tried:
public ActionResult Login(FormCollection fr)
{
Login t = new Login();
t.password = fr["password"];
t.username = fr["username"];
bool success = objIAccountData.Login(t);
if (success == true)
{
if (string.IsNullOrEmpty(Convert.ToString(LoginType)))
{
ModelState.AddModelError("Error", "Rights to User are not Provide Contact to Admin");
return View(login);
}
else
{
Session["Name"] = login.username;
Session["UserID"] = UserID;
Session["LoginType"] = LoginType;
if (Roles.IsUserInRole(login.username, "Admin"))
{
return RedirectToAction("AdminDashboard", "Dashboard");
}
else
{
return RedirectToAction("UserDashboard", "Dashboard");
}
}
}
else
{
ModelState.AddModelError("Error", "Please enter valid Username and Password");
return View(login);
}
return View(login);
}