Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC 2 authentication. The cookie faster lose a validation
    text
    copied!<p>After a convert MVC yo MVC 2 I get problems with authentication. In this project used standart membership.</p> <pre><code>[HandleError] public class AccountController : Controller { private readonly IServiceFactory _modelFactory; public AccountController(IServiceFactory _modelFactory) { this._modelFactory = _modelFactory; } public ActionResult LogOn() { return View(); } [HttpPost] public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl) { if (!this.ValidateLogOn(userName, password)) { return View(); } FormsAuthentication.RedirectFromLoginPage(userName, rememberMe); //FormsAuthentication.SetAuthCookie(userName, rememberMe); if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } return RedirectToAction(ControllerNaming.Action&lt;AdminController&gt;(x =&gt; x.Dashboard()), ControllerNaming.Name&lt;AdminController&gt;()); } public ActionResult LogOff() { FormsAuthentication.SignOut(); return RedirectToAction(ControllerNaming.Action&lt;HomeController&gt;(x =&gt; x.Default()), ControllerNaming.Name&lt;HomeController&gt;()); } protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.HttpContext.User.Identity is WindowsIdentity) { throw new InvalidOperationException("Windows authentication is not supported."); } } #region Validation Methods private bool ValidateLogOn(string userName, string password) { if (String.IsNullOrEmpty(userName)) { ModelState.AddModelError("username", "You must specify a username."); } if (String.IsNullOrEmpty(password)) { ModelState.AddModelError("password", "You must specify a password."); } if (!this.IsValidateUserNameAndPassword(userName, password)) { ModelState.AddModelError("password", "Password is not valid."); Thread.Sleep(5000); } return ModelState.IsValid; } private bool IsValidateUserNameAndPassword(string userName, string password) { IUser user = this._modelFactory.UserService.Login(userName, password); return user.IsValid; } #endregion } </code></pre> <p>and setting</p> <pre><code>&lt;authentication mode="Forms"&gt; &lt;forms cookieless="UseCookies" loginUrl="~/Account/LogOn" slidingExpiration="true" timeout="3000" /&gt; &lt;/authentication&gt; </code></pre> <p>I check in browse and I see the authentication cookie. But application want again login after 1-5 minutes if I'm nothing to do at page</p> <p>sessionState </p> <pre><code>&lt;sessionState timeout="150" &gt;&lt;/sessionState&gt; </code></pre> <p>But I have some one interesting fact. This application working fine at local IIS. But when I moved at Hosting I get this problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload