Application stops generating login cookies
I've been searching for an answer to this for a while but the problem seems quite complex and I'm struggling to find an answer.
I'm a beginner software developer working for a start up company and have just completed the first version system for use by multiple users. Locally Testing the software had no problems, but since publishing the software to a windows 2012 server on iis I have found a major problem with the Login system.
When the program is uploaded initially multiple users can log in and use the program with no problems, however (seemingly) at random the login system completely stops functioning on all computers that are currently logged out. Those who are logged in can logout and log back in with their account or any other, but those who were logged out at this moment complete lose access to the system.
When using the developer tools on Chrome it appears that all these computers completely stop generating the cookie created when logging in and just redirect back to the login screen.
The systems still recognise incorrect logins and it happens with different computers each time I upload the program.
I appreciate that this is a very vague question, but I'm pulling my hair out over it!
As I said I am a beginner and am completely new to hosting on business servers and don't have much experience with Identity or Login systems in general so any help is much appreciated.
I mainly want to know is the problem most likely iis, if so where in iis should I be looking? Or the servers security settings?
Is there an efficient why to debug this while its running on the server?
If the problem sounds like a coding issue where identity files have been edited let me know what class it could be and Ill post the code.
Thanks!
Edit:
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);
c# asp.net iis cookies session-cookies
|
show 5 more comments
I've been searching for an answer to this for a while but the problem seems quite complex and I'm struggling to find an answer.
I'm a beginner software developer working for a start up company and have just completed the first version system for use by multiple users. Locally Testing the software had no problems, but since publishing the software to a windows 2012 server on iis I have found a major problem with the Login system.
When the program is uploaded initially multiple users can log in and use the program with no problems, however (seemingly) at random the login system completely stops functioning on all computers that are currently logged out. Those who are logged in can logout and log back in with their account or any other, but those who were logged out at this moment complete lose access to the system.
When using the developer tools on Chrome it appears that all these computers completely stop generating the cookie created when logging in and just redirect back to the login screen.
The systems still recognise incorrect logins and it happens with different computers each time I upload the program.
I appreciate that this is a very vague question, but I'm pulling my hair out over it!
As I said I am a beginner and am completely new to hosting on business servers and don't have much experience with Identity or Login systems in general so any help is much appreciated.
I mainly want to know is the problem most likely iis, if so where in iis should I be looking? Or the servers security settings?
Is there an efficient why to debug this while its running on the server?
If the problem sounds like a coding issue where identity files have been edited let me know what class it could be and Ill post the code.
Thanks!
Edit:
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);
c# asp.net iis cookies session-cookies
Are you using forms authentication? if so is there any code in global.asax which creates a cookie and writes it to the response?
– Nilesh
Jul 30 '15 at 10:17
Thanks for the response, yes I use forms authentication, the only code in global.asax other than the default is creating a default admin role and registering a custom api. nothing about creating a cookie and writing a response... The method that creates the cookie is held in Stratup.auth.cs
– Verno
Jul 30 '15 at 11:35
Did you try to debug and check what happens when a user returns to the application? What is this startup.auth.cs ? are you using Owin Startup?
– Nilesh
Jul 30 '15 at 11:56
Yes, its owin start-up, the login system is just a custom version of the asp identity system that is part of a new web forms application. It was actually another developer that set up this side of the system, that's why I'm struggling to get my head round it!
– Verno
Jul 30 '15 at 12:14
As I understand the Owin Startup is invoked only when the application is first accessed. I believe you need to move the auth cookie code out of startup and probably add it in Global.asaxApplication_AuthenticateRequestrequest. It would be good if you could paste the startup which creates the cookie.
– Nilesh
Jul 30 '15 at 12:25
|
show 5 more comments
I've been searching for an answer to this for a while but the problem seems quite complex and I'm struggling to find an answer.
I'm a beginner software developer working for a start up company and have just completed the first version system for use by multiple users. Locally Testing the software had no problems, but since publishing the software to a windows 2012 server on iis I have found a major problem with the Login system.
When the program is uploaded initially multiple users can log in and use the program with no problems, however (seemingly) at random the login system completely stops functioning on all computers that are currently logged out. Those who are logged in can logout and log back in with their account or any other, but those who were logged out at this moment complete lose access to the system.
When using the developer tools on Chrome it appears that all these computers completely stop generating the cookie created when logging in and just redirect back to the login screen.
The systems still recognise incorrect logins and it happens with different computers each time I upload the program.
I appreciate that this is a very vague question, but I'm pulling my hair out over it!
As I said I am a beginner and am completely new to hosting on business servers and don't have much experience with Identity or Login systems in general so any help is much appreciated.
I mainly want to know is the problem most likely iis, if so where in iis should I be looking? Or the servers security settings?
Is there an efficient why to debug this while its running on the server?
If the problem sounds like a coding issue where identity files have been edited let me know what class it could be and Ill post the code.
Thanks!
Edit:
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);
c# asp.net iis cookies session-cookies
I've been searching for an answer to this for a while but the problem seems quite complex and I'm struggling to find an answer.
I'm a beginner software developer working for a start up company and have just completed the first version system for use by multiple users. Locally Testing the software had no problems, but since publishing the software to a windows 2012 server on iis I have found a major problem with the Login system.
When the program is uploaded initially multiple users can log in and use the program with no problems, however (seemingly) at random the login system completely stops functioning on all computers that are currently logged out. Those who are logged in can logout and log back in with their account or any other, but those who were logged out at this moment complete lose access to the system.
When using the developer tools on Chrome it appears that all these computers completely stop generating the cookie created when logging in and just redirect back to the login screen.
The systems still recognise incorrect logins and it happens with different computers each time I upload the program.
I appreciate that this is a very vague question, but I'm pulling my hair out over it!
As I said I am a beginner and am completely new to hosting on business servers and don't have much experience with Identity or Login systems in general so any help is much appreciated.
I mainly want to know is the problem most likely iis, if so where in iis should I be looking? Or the servers security settings?
Is there an efficient why to debug this while its running on the server?
If the problem sounds like a coding issue where identity files have been edited let me know what class it could be and Ill post the code.
Thanks!
Edit:
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);
c# asp.net iis cookies session-cookies
c# asp.net iis cookies session-cookies
edited Jul 31 '15 at 13:02
Mark Rotteveel
60.6k1478121
60.6k1478121
asked Jul 30 '15 at 10:05
VernoVerno
186115
186115
Are you using forms authentication? if so is there any code in global.asax which creates a cookie and writes it to the response?
– Nilesh
Jul 30 '15 at 10:17
Thanks for the response, yes I use forms authentication, the only code in global.asax other than the default is creating a default admin role and registering a custom api. nothing about creating a cookie and writing a response... The method that creates the cookie is held in Stratup.auth.cs
– Verno
Jul 30 '15 at 11:35
Did you try to debug and check what happens when a user returns to the application? What is this startup.auth.cs ? are you using Owin Startup?
– Nilesh
Jul 30 '15 at 11:56
Yes, its owin start-up, the login system is just a custom version of the asp identity system that is part of a new web forms application. It was actually another developer that set up this side of the system, that's why I'm struggling to get my head round it!
– Verno
Jul 30 '15 at 12:14
As I understand the Owin Startup is invoked only when the application is first accessed. I believe you need to move the auth cookie code out of startup and probably add it in Global.asaxApplication_AuthenticateRequestrequest. It would be good if you could paste the startup which creates the cookie.
– Nilesh
Jul 30 '15 at 12:25
|
show 5 more comments
Are you using forms authentication? if so is there any code in global.asax which creates a cookie and writes it to the response?
– Nilesh
Jul 30 '15 at 10:17
Thanks for the response, yes I use forms authentication, the only code in global.asax other than the default is creating a default admin role and registering a custom api. nothing about creating a cookie and writing a response... The method that creates the cookie is held in Stratup.auth.cs
– Verno
Jul 30 '15 at 11:35
Did you try to debug and check what happens when a user returns to the application? What is this startup.auth.cs ? are you using Owin Startup?
– Nilesh
Jul 30 '15 at 11:56
Yes, its owin start-up, the login system is just a custom version of the asp identity system that is part of a new web forms application. It was actually another developer that set up this side of the system, that's why I'm struggling to get my head round it!
– Verno
Jul 30 '15 at 12:14
As I understand the Owin Startup is invoked only when the application is first accessed. I believe you need to move the auth cookie code out of startup and probably add it in Global.asaxApplication_AuthenticateRequestrequest. It would be good if you could paste the startup which creates the cookie.
– Nilesh
Jul 30 '15 at 12:25
Are you using forms authentication? if so is there any code in global.asax which creates a cookie and writes it to the response?
– Nilesh
Jul 30 '15 at 10:17
Are you using forms authentication? if so is there any code in global.asax which creates a cookie and writes it to the response?
– Nilesh
Jul 30 '15 at 10:17
Thanks for the response, yes I use forms authentication, the only code in global.asax other than the default is creating a default admin role and registering a custom api. nothing about creating a cookie and writing a response... The method that creates the cookie is held in Stratup.auth.cs
– Verno
Jul 30 '15 at 11:35
Thanks for the response, yes I use forms authentication, the only code in global.asax other than the default is creating a default admin role and registering a custom api. nothing about creating a cookie and writing a response... The method that creates the cookie is held in Stratup.auth.cs
– Verno
Jul 30 '15 at 11:35
Did you try to debug and check what happens when a user returns to the application? What is this startup.auth.cs ? are you using Owin Startup?
– Nilesh
Jul 30 '15 at 11:56
Did you try to debug and check what happens when a user returns to the application? What is this startup.auth.cs ? are you using Owin Startup?
– Nilesh
Jul 30 '15 at 11:56
Yes, its owin start-up, the login system is just a custom version of the asp identity system that is part of a new web forms application. It was actually another developer that set up this side of the system, that's why I'm struggling to get my head round it!
– Verno
Jul 30 '15 at 12:14
Yes, its owin start-up, the login system is just a custom version of the asp identity system that is part of a new web forms application. It was actually another developer that set up this side of the system, that's why I'm struggling to get my head round it!
– Verno
Jul 30 '15 at 12:14
As I understand the Owin Startup is invoked only when the application is first accessed. I believe you need to move the auth cookie code out of startup and probably add it in Global.asax
Application_AuthenticateRequest request. It would be good if you could paste the startup which creates the cookie.– Nilesh
Jul 30 '15 at 12:25
As I understand the Owin Startup is invoked only when the application is first accessed. I believe you need to move the auth cookie code out of startup and probably add it in Global.asax
Application_AuthenticateRequest request. It would be good if you could paste the startup which creates the cookie.– Nilesh
Jul 30 '15 at 12:25
|
show 5 more comments
1 Answer
1
active
oldest
votes
Problem is now Solved.
For anyone with the same problem, the issue is caused by a bug called 'katana bug #197'.
The easiest fix is to download 'kentor.OwinCookieSaver' NuGet Package. and add app.UseKentorOwinCookieSaver(); above your Application cookie config in startup.
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 are aware of the issue and it will be resolved in 2015.
Instead of updating the question, you should have posted your own answer here instead of this comment. I have now moved your "answer" here and rolled back the edit to your question.
– Mark Rotteveel
Jul 31 '15 at 13:01
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31720820%2fapplication-stops-generating-login-cookies%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Problem is now Solved.
For anyone with the same problem, the issue is caused by a bug called 'katana bug #197'.
The easiest fix is to download 'kentor.OwinCookieSaver' NuGet Package. and add app.UseKentorOwinCookieSaver(); above your Application cookie config in startup.
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 are aware of the issue and it will be resolved in 2015.
Instead of updating the question, you should have posted your own answer here instead of this comment. I have now moved your "answer" here and rolled back the edit to your question.
– Mark Rotteveel
Jul 31 '15 at 13:01
add a comment |
Problem is now Solved.
For anyone with the same problem, the issue is caused by a bug called 'katana bug #197'.
The easiest fix is to download 'kentor.OwinCookieSaver' NuGet Package. and add app.UseKentorOwinCookieSaver(); above your Application cookie config in startup.
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 are aware of the issue and it will be resolved in 2015.
Instead of updating the question, you should have posted your own answer here instead of this comment. I have now moved your "answer" here and rolled back the edit to your question.
– Mark Rotteveel
Jul 31 '15 at 13:01
add a comment |
Problem is now Solved.
For anyone with the same problem, the issue is caused by a bug called 'katana bug #197'.
The easiest fix is to download 'kentor.OwinCookieSaver' NuGet Package. and add app.UseKentorOwinCookieSaver(); above your Application cookie config in startup.
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 are aware of the issue and it will be resolved in 2015.
Problem is now Solved.
For anyone with the same problem, the issue is caused by a bug called 'katana bug #197'.
The easiest fix is to download 'kentor.OwinCookieSaver' NuGet Package. and add app.UseKentorOwinCookieSaver(); above your Application cookie config in startup.
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 are aware of the issue and it will be resolved in 2015.
edited Jul 31 '15 at 13:02
Mark Rotteveel
60.6k1478121
60.6k1478121
answered Jul 31 '15 at 12:01
VernoVerno
186115
186115
Instead of updating the question, you should have posted your own answer here instead of this comment. I have now moved your "answer" here and rolled back the edit to your question.
– Mark Rotteveel
Jul 31 '15 at 13:01
add a comment |
Instead of updating the question, you should have posted your own answer here instead of this comment. I have now moved your "answer" here and rolled back the edit to your question.
– Mark Rotteveel
Jul 31 '15 at 13:01
Instead of updating the question, you should have posted your own answer here instead of this comment. I have now moved your "answer" here and rolled back the edit to your question.
– Mark Rotteveel
Jul 31 '15 at 13:01
Instead of updating the question, you should have posted your own answer here instead of this comment. I have now moved your "answer" here and rolled back the edit to your question.
– Mark Rotteveel
Jul 31 '15 at 13:01
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31720820%2fapplication-stops-generating-login-cookies%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you using forms authentication? if so is there any code in global.asax which creates a cookie and writes it to the response?
– Nilesh
Jul 30 '15 at 10:17
Thanks for the response, yes I use forms authentication, the only code in global.asax other than the default is creating a default admin role and registering a custom api. nothing about creating a cookie and writing a response... The method that creates the cookie is held in Stratup.auth.cs
– Verno
Jul 30 '15 at 11:35
Did you try to debug and check what happens when a user returns to the application? What is this startup.auth.cs ? are you using Owin Startup?
– Nilesh
Jul 30 '15 at 11:56
Yes, its owin start-up, the login system is just a custom version of the asp identity system that is part of a new web forms application. It was actually another developer that set up this side of the system, that's why I'm struggling to get my head round it!
– Verno
Jul 30 '15 at 12:14
As I understand the Owin Startup is invoked only when the application is first accessed. I believe you need to move the auth cookie code out of startup and probably add it in Global.asax
Application_AuthenticateRequestrequest. It would be good if you could paste the startup which creates the cookie.– Nilesh
Jul 30 '15 at 12:25