gpt4 book ai didi

c# - 名称 configureauth 不存在

转载 作者:太空狗 更新时间:2023-10-30 00:24:04 26 4
gpt4 key购买 nike

我正在尝试这个教程 http://httpjunkie.com/2013/311/adding-mvc-5-identity-to-an-existing-project/但它告诉我一个错误错误 5 The name 'ConfigureAuth' does not exist in the current context
这是我的 startup.cs 类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using Microsoft.Owin;
using Owin;

[assembly: OwinStartupAttribute(typeof(TicketSystem.Startup))]
namespace TicketSystem
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}



}
}

这是 Startup.Auth.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.Mvc;

using Microsoft.AspNet.Identity;
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;
namespace TicketSystem.App_Start
{
public partial class Startup
{

// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
// Use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

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

//app.UseTwitterAuthentication(
// consumerKey: "",
// consumerSecret: "");

//app.UseFacebookAuthentication(
// appId: "",
// appSecret: "");

//app.UseGoogleAuthentication();
}
}
}

最佳答案

两个文件中的 namespace 不同:namespace TicketSystem.App_Startnamespace TicketSystem。确保它们相同。或者在您的 startup.cs 类中添加 using 语句:using TicketSystem.App_Start。如果您检查示例,您会看到这两个文件都使用相同的命名空间 (namespace MVC5FullApp)

关于c# - 名称 configureauth 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30074179/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com