0

I'm working on some movie project. After the make some arrangements on HomeController this error showed up. I tried everything i could find on internet but cant solve it.

Here is my full error message.

InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[OnlineMovieTicketBookingProject.Models.ApplicationUser]' while attempting to activate 'OnlineMovieTicketBookingProject.Controllers.HomeController'.

HomeController.cs

public class HomeController : Controller
{
    int count = 1;
    bool flag = true;
    private UserManager<ApplicationUser> _usermanager;

    private ApplicationDbContext _context;
    public HomeController(ApplicationDbContext context, UserManager<ApplicationUser> usermanager)
    {
        _context = context;
        _usermanager = usermanager;
    }
    ...
}

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<ApplicationDbContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
    services.AddDatabaseDeveloperPageExceptionFilter();

    services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
        .AddEntityFrameworkStores<ApplicationDbContext>();
    services.AddControllersWithViews();
    services.AddTransient<UploadInterface, uploadfilerepo>();   
}
Peter Csala
  • 10,331
  • 15
  • 20
  • 47
  • Does this answer your question? [ASP.NET Core Identity does not inject UserManager](https://stackoverflow.com/questions/41679217/asp-net-core-identity-does-not-inject-usermanagerapplicationuser) – sommmen Jul 14 '21 at 07:19

0 Answers0