Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I working on c# web application i use the following code to login
but it not logged success

it show model state error although i have same user name and password on database
so how to solve this issue please

so when make break point to WebSecurity.Login it not go to inside if statement
it go to


i have same user name and password that exist on table webpages_Membership
so what i do to solve issue please

What I have tried:

public JsonResult Login(LoginModel model, string returnUrl)
            if (WebSecurity.Login(model.UserName, model.Password, model.RememberMe))


            ModelState.AddModelError("", "error");
            return Json(new { Ok = false, Message = main.LoginError, status = "activated" });
Updated 6-Nov-22 22:14pm

1 solution

Look at your code again - you have nothing inside the if block. Regardless of whether the Login method succeeds or fails, you always unconditionally return a "login error" response.

Change your code to return the expected response if the login succeeds.
Share this answer

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