Login and Registration In MVC


Dotnet-Expert

How to Create Login and Registration page in MVC

This article will show you how to create login and registration page in mvc using Entity Framework.
Step 1- Create Empty MVC Poject.
Step 2- Add 3 class to model folder. Users, Login, DemoContext.

Login.cs

using System.ComponentModel.DataAnnotations;

namespace SimpleWebSiteDemo.Models
{
    publicpartialclass Login
    {
        [Required(ErrorMessage = "User Name Required")]
        [Display(Name = "User Name")]
        [MinLength(4, ErrorMessage = "User Name Minimum Length Should Be 4 Char")]
        publicstring UserName { get; set; }

        [Required(ErrorMessage = "Password Required")]
        [DataType(DataType.Password)]
        [MinLength(6, ErrorMessage = "Password Minimum Length Should Be 6 Char")]
        publicstring Password { get; set; }
    }
}
Register.cs

using System.ComponentModel.DataAnnotations;

namespace SimpleWebSiteDemo.Models
{
    publicclass Users:Login
    {
        [Key]
        publicint Id { get; set; }
        [Required(ErrorMessage = "First Name Required")]
        [Display(Name = "First Name")] [MinLength(4, ErrorMessage…

View original post 1,028 more words