how to disable email confirmation when user creates an account in mvc asp identity

Use the following when configuring aspnet identity in the startup

In ConfigureServices()

services.AddIdentity<ApplicationUser, IdentityRole>(config =>
{
   config.SignIn.RequireConfirmedEmail = false;
})

Aspnet identity will then not check the EmailConfirmed flag when validating credentials during sign-in.


If you are using ASP.Net MVC simply confirm it while you are registering it. If you are using ASP.Net Core consider Tom's answer.

public async Task<ActionResult> Register(RegisterViewModel model)
{
    if (ModelState.IsValid)
    {
        var user = new ApplicationUser 
        { 
            UserName = model.Email, 
            Email = model.Email, 
            EmailConfirmed = true,
        };
        var result = await UserManager.CreateAsync(user, model.Password);
        if (result.Succeeded)
        {
            await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                
            return RedirectToAction("Index", "Home");
        }
        AddErrors(result);
    }
    return View(model);
 }

You can use this method instead of other cases, because in the future you may want to confirm the user's email by sending a link

   services.AddIdentity<ApplicationUser, IdentityRole>(options => 
        {
            options.SignIn.RequireConfirmedAccount = false;
            options.SignIn.RequireConfirmedEmail = false;
            options.SignIn.RequireConfirmedPhoneNumber = false;
        })