Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Adriano Fabri 469 posts 1633 karma points
    May 17, 2011 @ 12:44
    Adriano Fabri
    0

    Problem with Members authentication timeout

    Hi to all,
    I have a problem with members authentication.

    After I logged in with a member, the session never expire.

    This is what I set in the web.config:

    ***********************************************
    <authentication mode="Forms">
      <forms name="intranetAuth" 
             loginUrl="/it" 
             protection="All" 
             path="/" 
             timeout="10" />
    </authentication>
    ***********************************************

    This is the .cshtml file with the login form:

    ****************************************************************************************************************************

    @using System.Web
    @using System.Web.Configuration
    @using System.Web.Security
    @using System.Web.UI;

    @helper LoginForm()
    {
     <div id="masterLogin">
      <form name="frmMasterLogin" method="post" action="">
        <div class="content">
          <label for="masterUsername" /><input type="text" id="masterUsername" name="masterUsername" value="username" class="campo" />
          <label for="masterPassword" /><input type="password" id="masterPassword" name="masterPassword" value="password" class="campo" />
          <input type="submit" id="btnMasterLogin" name="btnMasterLogin" value="Accedi" class="submit" />

        </div>
      </form>
     </div>
    }

    @{
      var request HttpContext.Current.Request;
      var isSubmitLogin (request.HttpMethod == "POST" &request.Form["btnMasterLogin"== "Accedi");
      var isSubmitLogout (request.HttpMethod == "POST" &request.Form["btnMasterLogout"== "Disconnetti");
      var currentMember umbraco.cms.businesslogic.member.Member.GetCurrentMember();
      
      if (currentMember != null)
      {
       if (!isSubmitLogout)
       {
        var currentMemberType "/" @currentMember.ContentType.Text.ToLower().Replace(" ""-");
        //Response.Redirect(@currentMemberType);
        <input type="submit" id="btnMasterLogout" name="btnMasterLogout" value="Disconnetti" class="submit" />
       }
       else
       {
        umbraco.cms.businesslogic.member.Member.ClearMemberFromClient(@currentMember.Id);
        FormsAuthentication.SignOut();
        Response.Redirect("/?logout=true");
       }
      }
      else
      {
       if (!isSubmitLogin)
       {
        @LoginForm()
       }
       else
       {
        string username=request.Form["masterUsername"];
        string password=request.Form["masterPassword"];

        if (Membership.ValidateUser(usernamepassword))
        {
         FormsAuthentication.RedirectFromLoginPage(usernametrue);
        }
        else
        {
         <div class="errorLogin">Username Password errata (@username)</div>
         @LoginForm()
        }
       }
      }
     }
    ****************************************************************************************************************************

    I forgot something?
    Can anyone help me?

    Thank you in advance
    Adriano

Please Sign in or register to post replies

Write your reply to:

Draft