Nazwa „ConfigureAuth” nie istnieje w bieżącym kontekście

Nazwa „ConfigureAuth” nie istnieje w bieżącym kontekście

Jeśli używasz domyślnego szablonu projektu Visual Studio, ConfigureAuth metodę można znaleźć w częściowej klasie Startup.Auth.cs . Upewnij się więc, że niczego nie zepsułeś podczas modyfikowania struktury projektu.

To jest przykład ConfigureAuth metoda:

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

    // 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
    app.UseCookieAuthentication(new CookieAuthenticationOptions());
    app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

    // Configure the application for OAuth based flow
    PublicClientId = "self";
    OAuthOptions = new OAuthAuthorizationServerOptions
    {
        TokenEndpointPath = new PathString("/api/Token"),
        Provider = new ApplicationOAuthProvider(PublicClientId),
        AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
        AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
        AllowInsecureHttp = true
    };

    // Enable the application to use bearer tokens to authenticate users
    app.UseOAuthBearerTokens(OAuthOptions);
}

Miałem podobny problem, aby rozwiązać problem, usunąłem .App_Start z przestrzeni nazw w pliku Startup.Auth.cs. Po tym mogłem zobaczyć referencję.


Jest to albo:

    [assembly: **OwinStartup**(typeof(Project-Name.Startup))]
    namespace project-name
    {
        public partial class Startup
        {
            public void **Configuration**(IAppBuilder app)
                    {

LUB

    [assembly: **OwinStartupAttribute**(typeof(Project-Name.Startup))]
    namespace project-name
    {
        public partial class Startup
        {
            public void **ConfigureAuth**(IAppBuilder app)
                    {

Zmień nazwę OwinStartupAttribute na OwinStartupOR Configuration na ConfigureAuth