Reputation:
These error are coming in the Login function.
UserInfo(v.user_name, v.user_fname, v.user_bloodGp, v.user_nationality, v.usertype, v.status, v.gender, v.usercnic, v.user_passport, v.mobilenumber);
v.user_passport
, v.mobilenumber
is underlined and these errors are showing.
Error: Argument 9: Cannot convert from 'string' to 'int
Error: Argument 10:Cannot convert from 'int' to 'string'
Red Lines are shown under v.user_passport, v.mobilenumber); two parameters.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(User User)
{
var v = db.Users.Where(modal => modal.user_name.Equals(User.user_name)).Where(modal => modal.user_passport.Equals(User.user_passport)).SingleOrDefault();
if (v != null)
{
UserInfo(v.user_name, v.user_fname, v.user_bloodGp, v.user_nationality, v.usertype, v.status, v.gender, v.usercnic, v.user_passport, v.mobilenumber);
return RedirectToAction("Index");
}
return RedirectToAction("Wrongpassword");
}
public ActionResult UserInfo(string user_name,string user_fname,string usercnic,string user_passport,string user_bloodGp,string user_nationality,string usertype,string status,int mobilenumber,string gender)
{
Session["user_name"] = user_name;
Session["user_fname"] = user_fname;
Session["user_cnic"] = usercnic;
Session["user_passport"] = user_passport;
Session["user_bloodGp"] = user_bloodGp;
Session["user_nationality"] = user_nationality;
Session["usertype"] = usertype;
Session["status"] = status;
Session["mobilenumber"] = mobilenumber;
Session["gender"] = gender;
return new EmptyResult();
}
Upvotes: 1
Views: 2748
Reputation: 1514
Its run-time error. string is passed to variable where integer is expected and and its trying to cast string to integer causing Invalid cast exception. correct the order of parameters being passed.
Upvotes: 0
Reputation: 35
You can pass only the v
variable to your UserInfo
function instead of passing all those parameters
Upvotes: 1
Reputation: 235
You are not passing the parameters in the right order, modify your call to that:
UserInfo(v.user_name, v.user_fname, v.usercnic, v.user_passport, v.user_bloodGp, v.user_nationality, v.usertype, v.status, v.mobilenumber, v.gender);
If you are not using named parameters, you have always to be careful about the order of the parameters when you are calling a function/method
Upvotes: 2
Reputation: 235
Your mobilenumber is declared as int
, and you are trying to pass a string
, please do a cast when calling the UserInfo
UserInfo(v.user_name, v.user_fname, v.user_bloodGp, v.user_nationality, v.usertype, v.status, v.gender, v.usercnic, v.user_passport, int.Parse(v.mobilenumber));
Upvotes: 0