C# 如何在MVC5.NET中手动登录外部非数据库用户?

C# 如何在MVC5.NET中手动登录外部非数据库用户?,c#,asp.net,asp.net-mvc-5,asp.net-identity,owin,C#,Asp.net,Asp.net Mvc 5,Asp.net Identity,Owin,我正在尝试对数据库中不存在但来自外部提供者的用户进行身份验证 因此,我想手动创建一个新标识并使用Cookie身份验证登录: var claims = new[] { new Claim(ClaimTypes.Name, "Anonymous"), new Claim(ClaimTypes.Role, "Admin"), }; var applicationCookieIdentity = new ClaimsIdentity(claims

我正在尝试对数据库中不存在但来自外部提供者的用户进行身份验证

因此,我想手动创建一个新标识并使用Cookie身份验证登录:

var claims = new[] {
    new Claim(ClaimTypes.Name, "Anonymous"),
    new Claim(ClaimTypes.Role, "Admin"),
};

var applicationCookieIdentity = new ClaimsIdentity(claims, "ClientCookie");
var ctx = Request.GetOwinContext();
ctx.Authentication.SignIn(applicationCookieIdentity);
在my Startup.cs中,我定义了身份验证中间件:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = "ClientCookie",
    CookieName = CookieAuthenticationDefaults.CookiePrefix + "ClientCookie",
    ExpireTimeSpan = TimeSpan.FromMinutes(5)
});
这似乎不适用于
User.Identity.IsAuthenticated
始终返回false

SignIn方法不应该创建经过身份验证的用户标识吗