login feature of Website. RRS feed

  • Question

  • User1421620300 posted

    Can someone help me with correcting the issue that i am having with my login process to my website? I am currently building on a project and adding certain features to make it more dynamic. Just recently i added bootstrap snippet code to view, but previously was working with some instruction on how to make login process work! So now i have the template with the back-end code to the server that i want to use. But only thing is that when i compile there is no run time error or anything. So it make it difficult to even mange what is going on. When i login the screen just snaps with no error. I am using SSMS database for login credentials could someone go over my code and tell me where their is problem. Thanks, Markus33




    Tuesday, April 14, 2020 2:10 PM


  • User1535942433 posted

    Hi Markus33,

    Accroding to your description and codes,as far a I think,there are some problems with your codes,for example:

    1.The View is not calling the Verify() action in the controller.

    2.ConnectionStrings name is wrong.

    More details,you could refer to below codes:


        <meta name="viewport" content="width=device-width" />
        <script src="~/Scripts/jquery-3.0.0.min.js"></script>
        <script src="~/Scripts/bootstrap.min.js"></script>
        <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
        @using (Html.BeginForm("Verify", "Website"))
            <div class="sidenav">
                <div class="=login-main-text">
                    <h2>Application<br />Login Page</h2>
                    <p>Login or register from here to access.</p>
            <div class="main">
                <div class="col-md-6 col-sm-12">
                    <div class="login-form">
                        <div class="form-group">
                            <label>User Name</label>
                            <input name="name" type="text" class="form-control" placeholder="User Name" />
                        <div class="form-group">
                            <label>User Name</label>
                            <input name="password" type="text" class="form-control" placeholder="Password" />
                        <button type="submit" class="btn btn-black">Login</button>
                        <button type="submit" class="btn btn-secondary">Register</button>


            public ActionResult Index()
                return View();
            public ActionResult Verify(Account acc)
                string cs = ConfigurationManager.ConnectionStrings["CrudApp"].ConnectionString;
                SqlConnection connection = new SqlConnection(cs);
                string commandText = "SELECT * FROM login WHERE username=@Username AND password=@Password";
                SqlCommand command = new SqlCommand(commandText, connection);
                command.Parameters.AddWithValue("@Username", acc.name);
                command.Parameters.AddWithValue("@Password", acc.password);
                SqlDataReader dr = command.ExecuteReader();
                if (dr.Read())
                    TempData["Message"] = "Login failed.User name or password supplied doesn't exist.";
                return View();
            public class Account
                public string name { get; set; }
                public string password { get; set; }


        <add name="CrudApp" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=aspnet-TestApplicationWithDatabase-20190820030542;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" providerName="System.Data.SqlClient" />

    More details,you could refer to below article:


    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 15, 2020 6:58 AM