applicationUser error in the starupAuth.cs file RRS feed

  • Question

  • User-605499000 posted

    I thought that I had this solved but it came back and the errors are in the IdentiyModels. It is applicationUser and any change I make on it creates a GenerateUser error. I know that this is an Owin Identity issue but can't find the answer. Here is the code.  I took this from Wingtops program which I am adapting for my use.  It works on that program but not in the visual studio 2017 updates.

    using System;
    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using Microsoft.AspNet.Identity.Owin;
    using Microsoft.Owin;
    using Microsoft.Owin.Security.Cookies;
    using Microsoft.Owin.Security.DataProtection;
    using Microsoft.Owin.Security.Google;
    using Owin;
    using Bumples.Models;
    using static Bumples.ApplicationUserManager;

    namespace Bumples.HttpContext.Current.GetOwinContext
    public partial class Startup

    // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301883
    public void ConfigureAuth(IAppBuilder app)
    // Configure the db context, user manager and signin manager to use a single instance per request

    // Enable the application to use a cookie to store information for the signed in user
    // and to use a cookie to temporarily store information about a user logging in with a third party login provider
    // Configure the sign in cookie
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login"),
    Provider = new CookieAuthenticationProvider

    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(      (;) the error is the  ApplicationUser.
    validateInterval: TimeSpan.FromMinutes(30),
    regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
    // Use a cookie to temporarily store information about a user logging in with a third party login provider

    // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.

    app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

    // Enables the application to remember the second login verification factor such as phone or email.
    // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
    // This is similar to the RememberMe option when you log in.

    // Uncomment the following lines to enable logging in with third party login providers
    // clientId: "",
    // clientSecret: "");

    // consumerKey: "",
    // consumerSecret: "");

    // appId: "",
    // appSecret: "");

    app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
    ClientId = "000000000000.apps.googleusercontent.com",
    ClientSecret = "00000000000"

     I don't need to use google or twitter or facebook. If I take those off will that help.



    Thursday, October 25, 2018 4:04 AM

All replies

  • User-893317190 posted

    Hi bumples18,

    Could you post your error message  and the code which causes the error,it seems the error is not in your Startup.cs.

    You could also create a identity project in your project , microsoft has a sample project in visual studio and you could refer to it.

    Click Change Authentication and choose Individual User Accounts and the project will be created.

    Best regards,

    Ackerly Xu

    Friday, October 26, 2018 5:38 AM