Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3421264
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:05:21+00:00 2026-05-18T06:05:21+00:00

I need an app pool recycle to be completely transparent to the users of

  • 0

I need an app pool recycle to be completely transparent to the users of my web app.

Currently, upon an IIS 7 App Pool recycle all users logged into my web app are kicked out and are required to log back in (Context.User.Identity.IsAuthenticated is set to false). I employ SQL State Server, I use forms authentication and both are configured to use cookies. I was under the impression that .NET and/or IIS handles authentication of cookies.

However, every time the app pool is recycled Context.User.Identity.IsAuthenticated is set to false (and I’ve no idea where this occurs) my users are kicked out and are required to log back in. I can see that the session id remains the same throughout logins, I can also view this session information in the database/state server.

I can’t tell if this is a session or a cookie problem.

Please Help!

Logon method:

public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
    {
        if (!ValidateLogOn(userName, password))
        {
            return View();
        }

        FormsAuth.SignIn(userName, true);  // uses FormsAuthentication.SetAuthCookie(username, true);
        Session["userName"] = userName;

        if (!String.IsNullOrEmpty(returnUrl))
        {
            return Redirect(returnUrl);
        }
        else
        {
            return RedirectToAction("Index", "Home");
        }
    }

Custom Controller Attribute:

public class CookieAuthorizeAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        HttpContext lvContext = HttpContext.Current;

            if (!lvContext.User.Identity.IsAuthenticated)
            {
                lvContext.Response.Redirect("~/Account/Logon");
            }
            else
            {
                FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity;
                FormsAuthentication.RenewTicketIfOld(identity.Ticket);
            }

        base.OnActionExecuting(filterContext);
    }
}

WebConfig:

<authentication mode="Forms">
  <forms cookieless="UseCookies" loginUrl="~/Account/LogOn" slidingExpiration="true" name=".ASPXAUTH" requireSSL="false" timeout="2880" />
</authentication>

<modules runAllManagedModulesForAllRequests="true">
  <remove name="ScriptModule" />
  <remove name="UrlRoutingModule" />
  <remove name="Session" />
  <remove name="FormsAuthentication" />
  <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <add name="NHibernateMvcSessionModule" type="EpnNHibernateBase.NHibernateMvcSessionModule, EpnNHibernateBase" />
  <add name="Session" type="System.Web.SessionState.SessionStateModule" />
  <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
</modules>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:05:21+00:00Added an answer on May 18, 2026 at 6:05 am

    I was able to find a solution on my own. The problem was not with how authentication was handled programmatically or how I was authenticating users. The problem was with how I had configured the authentication in IIS/web.config.

    I carefully followed the steps in the links listed below:

    Configuring Forms Authentication (IIS 7) (Branching out on every related section)

    Configuring Machine Keys in IIS 7 <– This one in particular

    After having followed those steps closely I was able to correctly generate a machine key.
    This machine key is as follows (with a fabricated key):

    <machineKey decryptionKey="ASDF3WS545AS5D4F8254A12DAFA5SDF7,IsolateApps" validation="3DES" validationKey="A65A6S5DF46ASD4F89WEF6SAD2F4A68EF4AW65F4D3A2F4AS6DF89A98D4F6A5SD4F6A5SDF46ASD8F4A6S5DF46AS5D4F6AS5DF49AS8DF46AS5D4F6AS5DF46SAD5F,IsolateApps" />
    

    Additionally, httpModules and system.webServer:modules sections in the web.config required the addition of the following modules:

    <remove name="Session" />
    <remove name="FormsAuthentication" />
    <add name="Session" type="System.Web.SessionState.SessionStateModule" />
    <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
    

    Summary: From what I gather, cookies were being created and encrypted, but because there was no machine key I was unable to unencrypt the cookie, thus causing the need to reauthenticate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've inherited a web app in need of some maintenance and all of the
In my app users need to be able to enter numeric values with decimal
I need to restart an app pool from code, does anyone know how to
My ASP.NET web app runs fine under IIS 7.5. But I want to make
I'm building a mobile app for Android and I need to pool HTTP requests
my app need to show user scrollable menu bar under tab bar like fox
I need an app that sends an UDP packet to some network server and
I need my app to show as full screen. Now I know how to
Something like phpmyadmin but for Ruby on Rails ? I need an app to
I need to store app specific configuration in rails. But it has to be:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.