Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My Code is bellow....
C#
 public ActionResult Login(user model, string returnUrl="/Home")
 {
    if (ModelState.IsValid && WebSecurity.Login(model.UserFirstName, model.Password))
           {
               return RedirectToLocal(returnUrl);
           }

           // If we got this far, something failed, redisplay form
  ModelState.AddModelError("", "The user name or password provided is incorrect.");
  return View(model);
}


And error is..
You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.
Posted
Updated 2-May-17 19:09pm

Use [InitializeSimplemembership] above the controllername means

[InitializeSimplemembership]
/// Here your controller starts
 
Share this answer
 
Comments
Nirav Prabtani 3-May-17 10:05am    
Posted 20-Jun-15 16:56pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900