Hadeer Mohamed

Hadeer Mohamed

  • NA
  • 3
  • 854

How to make WCF for Login function using ASP.NET MVC4

Dec 19 2018 8:24 PM
i can't read from database then compare this string with the parameter of certain function
i'm using ASP.net MVC4
i tried that i create WCF as following :
public int login_service (string username, string password)
{
OnlineFoodOrderingEntities user1 = new OnlineFoodOrderingEntities();
var x = from n in user1.users select n;
List tst= x.ToList();
 foreach (var u in tst)
{
if (u.username == username && u.password == password )
{return 1;}
else{return 0;}
}
then in MVC application
public ActionResult Login(string username, string password)
{
ServiceReference1.ServiceClient sc = new ServiceReference1.ServiceClient();
int check = sc.login_service(username,password);
if ( check == 1)
{
return RedirectToAction("cuisine", "Home");
}
else
{
return View();
}
}
the database is called OnlineFoodOrdering
and the table is called user
i want when the check variable is equle to "1" it redirect to Home/cuisine.
please any help
thanks in advance

Answers (1)