Click here to Skip to main content
15,891,712 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I created an access login for my website project. I have to kind of admin. one have full access and second limited access. I searched and learned how to use viewBag, session, cookies,... but I have obsession about which is more secure and really I was too stupid for know how to attach those in my own project :D

I want two things:
1- how set limit on two of them (admins) or more?
2- how show him (admin), his name? (I think it's viewbag but not sure because I want use my css class on income from controller)
thank you for your help

What I have tried:

namespace Homi.Controllers
{
  public class AuthenticationController : Controller
  {
    private modelLayOut mLO = new modelLayOut();

    [HttpPost]
    public ActionResult webAdminAccess(string Username, string Password)
    {
        if (mLO.webAdminAccess(Username, Password))
        {
            return RedirectToAction("webAdminPage", "Admin");
        }
        else
        {
            return View("webAdminAccessWrong");
        }
    }
  }
}


Razor
@{
    Layout = null;
    @ViewBag.Title;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
    <div class="pen-title">
        <h1>adminAccess</h1>
    </div>
    <div class="container">
        @using (Html.BeginForm("webAdminAccess", "Authentication"))
        {
            <div class="card"></div>
            <div class="card">
                <h1 class="title">Login</h1>
                <form>
                    <div class="input-container">
                        <input type="text" name="Username" required="required" />
                        <label for="Username">Username</label>
                        <div class="bar"></div>
                    </div>
                    <div class="input-container">
                        <input type="password" name="Password" required="required" />
                        <label for="Password">Password</label>
                        <div class="bar"></div>
                    </div>
                    <div type="submit" class="button-container">
                        <button><span>Go</span></button>
                    </div>
                    <div class="footer"><a href="#">Forgot your password?</a></div>
                </form>
            </div>
        }
</body>
</html>
Posted

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