The name "ConfigureAuth" does not exist in the current content

I get an error when I try to launch my page, it says that

The name "ConfigureAuth" does not exist in the current context

in my class Stratup . I am sure that all AspNet Identity libraries AspNet Identity installed. What do I need to do next to fix this?

 using Microsoft.Owin; using Owin; [assembly: OwinStartupAttribute(typeof(project_name.Startup))] namespace project_name { public partial class Startup { public void Configuration(IAppBuilder app) { ConfigureAuth(app); } } } 
+5
source share
5 answers

If you use the standard Visual Studio project template, the ConfigureAuth method can be found in the Startup.Auth.cs partial class. Therefore, make sure that you do not break anything when changing the structure of the project.

This is an example of the ConfigureAuth method:

 // 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); } 
+4
source

I had a similar problem. To fix the problem that I removed .App_Start from the namespace in the Startup.Auth.cs file. After that, I was able to see the link.

+4
source

Remember that two partial classes ( Startup.Auth.cs and Startup.cs ) must be in the same namespace that is the root of the project, just change the Startup.Auth.cs namespace to the same Startup.cs namespace

+1
source

Make sure that when you initially created the project, there are no spaces in it. for example, my application was called "DevOps Test", which gave me errors when I ran it. I recreated it as "DevopsTest" and no longer had these problems.

0
source

It is either:

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

OR

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

Rename OwinStartupAttribute to OwinStartup OR Configuration for ConfigureAuth

0
source

Source: https://habr.com/ru/post/1212404/


All Articles