I was changing some things on a new startup file of a ASP.NET MVC site and I'm getting a null error:
System.ArgumentNullException: Value cannot be null. Parameter name: context
IdentityConfig file:
using -
using Microsoft.AspNet.Identity.Owin;
using Microsoft.AspNet.Identity;
...snip...
public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<IdentityDb>()));
// Configure validation logic for usernames
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = true
};
IdentityDb file :
public class IdentityDb : IdentityDbContext<ApplicationUser>
{
public IdentityDb()
: base("DefaultConnection")
{
}
}
I don't know if I am missing something with Microsoft.AspNet.Identity.Owin.IdentityFactoryProvider?
Server Error in '/' Application.
Value cannot be null. Parameter name: context
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: context
Full Stack Trace :
Source Error:
Line 40: public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
Line 41: {
Line 42: var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<IdentityDb>()));
Line 43: // Configure validation logic for usernames
Line 44: manager.UserValidator = new UserValidator<ApplicationUser>(manager)
Source File: c:\users\aindriu\documents\visual studio 2015\Projects\Books\Books.Web\App_Start\IdentityConfig.cs Line: 42
Stack Trace:
[ArgumentNullException: Value cannot be null.
Parameter name: context]
Microsoft.AspNet.Identity.EntityFramework.UserStore`6..ctor(DbContext context) +335
Microsoft.AspNet.Identity.EntityFramework.UserStore`1..ctor(DbContext context) +5
Books.Web.ApplicationUserManager.Create(IdentityFactoryOptions`1 options, IOwinContext context) in c:\users\aindriu\documents\visual studio 2015\Projects\Books\Books.Web\App_Start\IdentityConfig.cs:42
Microsoft.AspNet.Identity.Owin.IdentityFactoryProvider`1.Create(IdentityFactoryOptions`1 options, IOwinContext context) +14
Microsoft.AspNet.Identity.Owin.<Invoke>d__0.MoveNext() +104
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<RunApp>d__5.MoveNext() +187
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<DoFinalWork>d__2.MoveNext() +185
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +69
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) +64
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +380
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155