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 7492937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:40:13+00:00 2026-05-29T16:40:13+00:00

I am using the built in Forms authentication in an MVC3 application. The issue

  • 0

I am using the built in Forms authentication in an MVC3 application. The issue I am currently facing is that the cookies slidingexpiration is not working.

The web.config file has the following line:

<forms loginUrl="/auth" name="authy" path="/" slidingExpiration="true" />

note:: I have declared slidingexpiration even though the default is true.

Within my code I am making use of the basic Membership Provider class with no extending or modification. My global.asax file is using the system default.

There is no point in adding a code example as this is just a base project with no extra code added. I am using the FormsAuthentication.SetAuthCookie(username, true); to set the cookies initially.

  • 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-29T16:40:16+00:00Added an answer on May 29, 2026 at 4:40 pm

    Quote from the documentation:

    Sliding expiration resets the expiration time for a valid
    authentication cookie if a request is made and more than half of the
    timeout interval has elapsed. If the cookie expires, the user must
    re-authenticate. Setting the SlidingExpiration property to false can
    improve the security of an application by limiting the time for which
    an authentication cookie is valid, based on the configured timeout
    value.

    2 very important things to notice in this quote:

    1. … if a request is made …
    2. … half of the timeout interval ….

    You haven’t specified a timeout so the default value of 30 minutes will be used.

    Another important thing to notice in this quote:

    Setting the SlidingExpiration property to false can improve the
    security

    but I guess you don’t care about security since you have activated it.


    UPDATE:

    Here’s a full example illustrating the concept:

    Controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            FormsAuthentication.SetAuthCookie("foo", true);
            return View();
        }
    
        [Authorize]
        public ActionResult Foo()
        {
            return Json(User.Identity.Name + " is still authenticated", JsonRequestBehavior.AllowGet);
        }
    }
    

    View:

    <script type="text/javascript">
        $(function () {
            (function () {
                var caller = arguments.callee.caller;
                window.setTimeout(function () {
                    $.getJSON('@Url.Action("foo")', function (result) {
                        $('#msg').append($('<div/>', { text: result }));
                        caller();
                    });
                }, 10000);
            })();
        });
    </script>
    
    <div id="msg"></div>
    

    web.config:

    <authentication mode="Forms">
        <forms 
            loginUrl="/auth" 
            name="authy" 
            path="/" 
            slidingExpiration="true" 
            timeout="1" 
        />
    </authentication>
    

    No matter how long you stay on the Index view, the user will still be authenticated.

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

Sidebar

Related Questions

I have a web application built in asp.net mvc using forms authentication. I am
I've built an ASP.NET application that's using Forms Authentication. In our hosting account control
I am using the built-in forms authentication that comes with asp.net mvc. I added
I have forms authentication already built in my web application. Can I have Windows
Currently, when the using is logged in (using the built in forms authentication) and
I'm using Forms Authentication (and the built in Login controls) and letting users click
My users are having an intermittent error when using a Windows Forms application built
In my asp.net webforms application I am using plain and simple forms authentication hooked
I am working on web application that requires that users are put into roles
I just built an application with forms authentication. I am unable to see my

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.