Skip to content
Loading
 
 and assign usertype as user in your Regis post method
  1. public ActionResult Regis(stanstud studs)  
  2. {  
  3.     studs.usertype = "User";  
  4.     context.studs.Add(studs);  
  5.     context.SaveChanges();  
  6.     return View();  
  7. } 
0
  • 0
    @Amit Mohanty thanks ragistration is successful but i add a one admin record manually then login not work plz help
    0
  • 0
    @AmitMohanty  I few changes in login code
     
    1. if (userdata != null)  
    2.             {  
    3.                 if (userdata.password == userdata.password) 
    4.                 {  
    5.                     HttpContext.Session.SetInt32("id", userdata.id);    //here give an error  httpsessionstatebase does not contain definition for setint32 and no extension method setnt32 are u missing directive or assembley referance???
    6.                     if (userdata.usertype == "Admin")  
    7.                         return RedirectToAction("Index", "Home");  
    8.                     else  
    9.                         return RedirectToAction("ClientView", "Home");  
    10.                 }  
    11.                 else  
    12.                 {  
    13.                     ViewBag.Message = "Invalid Password!";  
    14.                     return View();  
    15.                 }  
    16.             }  
    17.             else  
    18.             {  
    19.                 ViewBag.Message = "Invalid Email!";  
    20.                 return View();  
    21.             }  
    0
  • Amit Mohanty
    0
    Hey you need to install the stable version of “Microsoft.AspNetCore.Session” from the NuGet Package Manager for the given error.
    0