Gcobani Mkontwana

Gcobani Mkontwana

  • 566
  • 1.9k
  • 406k

The type or namespace ApplicationSignInManager could not be

Feb 25 2020 12:18 AM
Hi Team
 
I have this error ' The namespace or type ApplicationSignInManager, ApplicationUserManager, ApplicationRoleManager could not be found, missing some directive'.  The problem is i do have the relevant assemblies but i am still getting this issue and did clean as well built my applicatio. Please help me mates to resolve this issue. 
  1. // HomeController  
  2.   
  3. using System;  
  4. using eNtsaTrainingRegistration.Models;  
  5. using Microsoft.AspNet.Identity.Owin;  
  6. using System.IO;  
  7. using System.Configuration;  
  8. using System.Net.Http;  
  9. using System.Net.Http.Headers;  
  10. using System.Text.RegularExpressions;  
  11. using System.Threading.Tasks;  
  12. using System.Collections.Generic;  
  13. using System.Linq;  
  14. using System.Web;  
  15. using System.Web.Mvc;  
  16. using eNtsaTrainingRegistration.Helper;  
  17. using eNtsaTrainingRegistration.App_Start;  
  18.   
  19.   
  20. namespace eNtsaTrainingRegistration.Controllers  
  21. {  
  22.     [HandleError(ExceptionType = typeof(Exception), View = "InternalError")]  
  23.     public class HomeController : AppBaseController  
  24.     {  
  25.         // GET: Home  
  26.   
  27.         private ApplicationSignInManager _signInManager;  
  28.         private ApplicationUserManager _userManager;  
  29.         private ApplicationRoleManager _roleManager;  
  30.   
  31.         public HomeController()  
  32.         {  
  33.   
  34.         }  
  35.   
  36.         public HomeController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ApplicationRoleManager roleManager)  
  37.         {  
  38.             UserManager = userManager;  
  39.             SignInManager = signInManager;  
  40.             AppRoleManager = roleManager;  
  41.         }  
  42.   
  43.   
  44.         public ApplicationSignInManager SignInManager  
  45.         {  
  46.             get  
  47.             {  
  48.                 return _signInManager ?? HttpContext.GetOwinContext().Get<ApplicationSignInManager>();  
  49.             }  
  50.             private set  
  51.             {  
  52.                 _signInManager = value;  
  53.             }  
  54.         }  
  55.   
  56.         public ApplicationUserManager UserManager  
  57.         {  
  58.             get  
  59.             {  
  60.                 return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();  
  61.             }  
  62.             private set  
  63.             {  
  64.                 _userManager = value;  
  65.             }  
  66.         }  
  67.   
  68.         public ApplicationRoleManager AppRoleManager  
  69.         {  
  70.             get  
  71.             {  
  72.                 return _roleManager ?? Request.GetOwinContext().GetUserManager<ApplicationRoleManager>();  
  73.             }  
  74.             private set  
  75.             {  
  76.                 _roleManager = value;  
  77.             }  
  78.         }  
  79.   
  80.   
  81.         [AuthorizeRole(Roles = "SuperAdmin, AdminUser, PendingUSers")]  
  82.         [OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")]  
  83.         public ActionResult Index()  
  84.         {  
  85.             var pendingUserRoleId = AppRoleManager.Roles.SingleOrDefault(r => r.Name == "PendingUsers").Id;  
  86.             var pendingUsers = (from user in UserManager.Users  
  87.                                 select new  
  88.                                 {  
  89.                                     UserId = user.Id,  
  90.                                     Username = user.FirstName,  
  91.                                     Useremail = user.Email,  
  92.                                     UserroleId = user.Roles.FirstOrDefault().RoleId,  
  93.                                     EmailConf = user.EmailConfirmed,  
  94.                                 })  
  95.                                 .Where(u => u.UserroleId == pendingUserRoleId)  
  96.                                 .Where(u => u.EmailConf == true)  
  97.                                 .Select(p => new RoleViewModel()  
  98.                                 {  
  99.   
  100.                                 });  
  101.   
  102.             return View(pendingUsers);  
  103.         }  
  104.         protected override void Dispose(bool disposing)  
  105.         {  
  106.             if(_userManager !=null)  
  107.             {  
  108.                 _userManager.Dispose();  
  109.                 _userManager = null;  
  110.             }  
  111.             if(_signInManager !=null)  
  112.             {  
  113.                 _signInManager.Dispose();  
  114.                 _signInManager = null;  
  115.             }  
  116.             if(_roleManager !=null)  
  117.             {  
  118.                 _roleManager.Dispose();  
  119.                 _roleManager = null;  
  120.             }  
  121.   
  122.             base.Dispose(disposing);  
  123.         }  
  124.   
  125.     }  
  126.   
  127.   
  128. }  
 

Answers (12)