You must Sign In to post a response.
  • Category: ASP.Net MVC

    Custom authentication and authorization in mvc 5 application


    I have 2 tables in my database. 1)EMP(Id,Name,Password,RoleID)
    2)Roles(Id,Description). I have 3 records in my emp tables who is having the roles ADMIN,SemiAdmin,User.

    I have 3 links like page1,page2, page3 in home page. I want to show 3 links( page1,page2, page3) for Admin,2 links(page2, page3) for SemiAdmin and 1 link(page3) for user.

    Any one suggest me how to implement authentication and authorization in mvc 5 application.

  • #766277
    Created Table Structure follow this

    Employee Table

    Create Table EMP
    Id primary key identity(1,1),
    Name varchar(50),
    Password varchar(50),
    RoleID INT

    Roles Table Script

    Create Table Roles(
    Id primary key identity(1,1),
    Description varchar(20)

    after then CREATE EDMX corresponding table then retrieve data and restricted them.

    Name : Dotnet Developer-2015
    Email Id

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #766304

    In one of my article I explore how to perform Form Authentication in MVC architectural pattern. I share you that knowledge with you, may be this will helpful to you.

    1) Create AuthenticationController and Login action method
    2) Create Model & View,
    3) Enable Forms Authentication

    <authentication mode="Forms" >
    <forms loginUrl="Authentication/Login"></forms>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />

    4) Make Action method secured

    public ActionResult Index()
    //your action here

    These are the basic steps to create Authentication and apply the same in your Action, refer below link for more details about the same.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

Sign In to post your comments