我一直在寻找答案,但问题似乎很复杂,我很难找到答案。
我是一家为初创公司工作的初学软件开发人员,刚刚完成了第一个版本系统,供多个用户使用。本地测试软件没有问题,但自从在iis上将软件发布到Windows 2012服务器后,我发现登录系统存在一个主要问题。
当程序上传时,最初多个用户可以登录并使用该程序没有任何问题,但是(看似)随机地(登机)登录系统完全停止在当前登出的所有计算机上运行。登录的用户可以注销并使用他们的帐户或任何其他帐户重新登录,但此时已注销的用户将无法访问系统。
在Chrome上使用开发者工具时,似乎所有这些计算机都完全停止生成登录时创建的cookie,只是重定向回登录屏幕。
系统仍会识别不正确的登录,每次上传程序时都会在不同的计算机上发生。
我很欣赏这是一个非常模糊的问题,但是我把头发拉过来了!
正如我所说,我是一名初学者,对于在商业服务器上托管而言我是全新的,并且在身份或登录系统方面没有多少经验,因此非常感谢任何帮助。
我主要想知道最有可能的问题是iis,如果是这样,我应该在哪里看?还是服务器安全设置?
在服务器上运行时,为什么调试它有效?
如果问题听起来像是编辑身份文件的编码问题,请让我知道它可以是什么类,然后发布代码。
谢谢!
编辑:
的Global.asax.cs
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
WebApiConfig.Register(GlobalConfiguration.Configuration);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
//Creates roles and adds an admin on first start
RoleCreator rc = new RoleCreator();
rc.CreateRoles();
rc.AddAdmin();
}
}
Startup.Auth.cs
public partial class Startup {
public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context, user manager and signin manager to use a single instance per request
app.CreatePerOwinContext(UnitContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.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
// Configure the sign in cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
CookieName="TrackerCookie",
LoginPath = new PathString("/Login/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
// Use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
// Enables the application to remember the second login verification factor such as phone or email.
// Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
// This is similar to the RememberMe option when you log in.
app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
}
答案 0 :(得分:2)
问题现在解决了。
对于有同样问题的人,问题是由一个名为“katana bug#197”的错误引起的。
最简单的解决方法是下载'kentor.OwinCookieSaver'NuGet Package。并在启动时将app.UseKentorOwinCookieSaver();
添加到应用程序cookie配置之上。
https://github.com/KentorIT/owin-cookie-saver
// kentor.OwinCookieSaver for 'katana bug #197' (login cookies being destroyed on logout!)
app.UseKentorOwinCookieSaver();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
CookieName="LoginCookie",
LoginPath = new PathString("/Login/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
Microsoft已发现此问题,并将于2015年解决。