您好我想知道是否有可能通过使用asp.net身份asp.net身份multipe用户登录
对于例如有管理员登录页面和普通用户,这对于在同一Web应用程序两个差网站的多个登录页面登录页面。一旦用户已经登录到管理员。用户还允许在不注销管理站点的情况下再次登录到普通用户页面。顺便说一句会有两个区别的用户名
有没有人有任何想法如何做到这一点?这是对asp.net身份的限制,只允许整个asp.net中的一个登录页面?
感谢,
您好我想知道是否有可能通过使用asp.net身份asp.net身份multipe用户登录
对于例如有管理员登录页面和普通用户,这对于在同一Web应用程序两个差网站的多个登录页面登录页面。一旦用户已经登录到管理员。用户还允许在不注销管理站点的情况下再次登录到普通用户页面。顺便说一句会有两个区别的用户名
有没有人有任何想法如何做到这一点?这是对asp.net身份的限制,只允许整个asp.net中的一个登录页面?
感谢,
如果你想用管理员帐户和明年与用户帐户你可以与其他浏览器或专用模式访问网站登录登录。我不知道你想做什么,但如果它只是为了测试,你可以做到这一点。
晚了,但可能会帮助别人。据Pinpoint Answer上类似的问题,你可以做这样的事情在启动类定制:
using System;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;
using Microsoft.AspNet.Identity;
public partial class Startup {
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
// Basic for site guest
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
LogoutPath = new PathString("/Account/Logout"),
Provider = new CookieAuthenticationProvider {
OnApplyRedirect = RedirectIfAdmin,
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
}
private static void RedirectIfAdmin(CookieApplyRedirectContext context)
{
// If Url contains
Uri absoluteUri;
if (Uri.TryCreate(context.RedirectUri, UriKind.Absolute, out absoluteUri))
{
string path = context.Request.PathBase + context.Request.Path + context.Request.QueryString;
if (path.Contains("/administration")) {
context.RedirectUri = "/administration/login.aspx" +
new QueryString(context.Options.ReturnUrlParameter, context.Request.Uri.AbsoluteUri);
}
}
context.Response.Redirect(context.RedirectUri);
}
谢谢,我会寻找它 – user998405