问题描述
我得到的错误,当我尝试运行我的网页,上面写着:我的Stratup类'ConfigureAuth'这个名字并不在目前的情况下存在。我已经确定所有的ASPNET标识库安装。我需要做什么接下来要做,试图解决这个问题?
使用Microsoft.Owin;
使用Owin;
[大会:OwinStartupAttribute(typeof运算(project_name.Startup))]
命名空间PROJECT_NAME
{
公共部分类启动
{
公共无效配置(IAppBuilder应用程序)
{
ConfigureAuth(应用);
}
}
}
如果您使用的是默认的Visual Studio项目模板,在 ConfigureAuth
方法可以在局部类中找到 Startup.Auth.cs
。因此,请确保修改项目结构,当你没有破坏任何东西。
这是 ConfigureAuth
方法的一个例子:
//有关配置身份验证的详细信息,请访问http://go.microsoft.com/fwlink/?LinkId=301864
公共无效ConfigureAuth(IAppBuilder应用程序)
{
//配置数据库环境和用户管理使用每个请求的单个实例
app.CreatePerOwinContext< ApplicationUserManager>(ApplicationUserManager.Create); //使应用程序能够使用cookie来存储信息,在用户签订
//并利用cookie来临时存储有关用户记录的信息与第三方供应商登录
app.UseCookieAuthentication(新CookieAuthenticationOptions());
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); //配置基于流的OAuth应用
PublicClientId =自我;
OAuthOptions =新OAuthAuthorizationServerOptions
{
TokenEndpointPath =新PathString(/ API /令牌),
供应商=新ApplicationOAuthProvider(PublicClientId)
AuthorizeEndpointPath =新PathString(/ API /帐号/ ExternalLogin),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp =真
}; //启用应用程序使用承载令牌来验证用户身份
app.UseOAuthBearerTokens(OAuthOptions);
}
I'm getting Error when I attempt to run my page that says, "The name 'ConfigureAuth' does not exist in the current context " in My Stratup Class . I have made sure all "AspNet Identity" libraries are installed. What do I need to do next to try 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);
}
}
}
If you are using default Visual Studio project template, the ConfigureAuth
method could be found in partial class Startup.Auth.cs
. So make sure you didn't break anything when modifying project structure.
This is an example of 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);
}
这篇关于“ConfigureAuth'这个名字并不在当前存在CONTEX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!