未经授权的asp.net身份时返回字符串而不是视图

时间:2018-05-05 03:50:14

标签: c# asp.net-web-api asp.net-identity

我使用ASP.net身份,它允许我配置为未经授权返回视图,但现在我想返回字符串,所以我需要做什么?

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {                   
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                },
                ExpireTimeSpan = TimeSpan.FromMinutes(1),
            });

1 个答案:

答案 0 :(得分:1)

创建一个控制器,它将返回字符串并将其放在LoginPath