Forms authentication not working right

From: Joe (J_no_spam_at__no_spam_Fishinbrain.com)
Date: 07/29/05

  • Next message: Joe: "Re: Forms Authentication: <location> authorization not bypasssing login page."
    Date: Fri, 29 Jul 2005 15:26:47 -0400
    
    

    I have a subfolder protected with Forms Authentication. When any page in
    that folder is requested my login page comes up and the user is prompted to
    login. This works fine.
    Once the user info is validated I create a cookie and setup the
    FormsAuthentication.

    The problem I get is that the Redirect always gets kicked back to the login
    page.

    FormsAuthentication.Initialize();

        FormsAuthenticationTicket ticket;
        string cookieString;
        HttpCookie cookie;

        ticket = new FormsAuthenticationTicket(1,
         user.Text,
         DateTime.Now,
         DateTime.Now.AddMinutes(30),
         false,
         "Data",
         FormsAuthentication.FormsCookiePath);

        cookieString = FormsAuthentication.Encrypt(ticket);
        cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
    cookieString);
        Response.Cookies.Add(cookie);
        string strQuery = FormsAuthentication.GetRedirectUrl(user.Text,false);
        Response.Redirect(strQuery);

    <location path="Publisher">
      <system.web>
       <compilation defaultLanguage="c#" debug="true" />
       <customErrors mode="Off" />
       <authentication mode="Forms">
        <forms name=".ASPXAUTH" loginUrl="..\PublisherLogin.aspx" timeout="30">
        </forms>

       </authentication>
       <authorization>
        <deny users="?" />
        <allow users ="*"/>
       </authorization>
      </system.web>
     </location>

    I had this problem another time but can't remember how I fixed it...

    Thanks,
    Joe


  • Next message: Joe: "Re: Forms Authentication: <location> authorization not bypasssing login page."

    Relevant Pages

    • RE: A little problem with Forms authentication :-(
      ... I'm using forms authentication and the user is getting authenticated no ... should be redirected to the login page. ... I've set the time out for the cookie to the test value of 1 ... redirect from login bit because as I understand it, ...
      (microsoft.public.dotnet.framework.aspnet)
    • RE: Forms authentication cookie handling question (C#)
      ... programmatically generate forms authentication ticket and set it in ASP.NET ... You use the Login control's "Authentication" event to do the user ... LoginControl's default code logic to generate authentication cookie. ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: Forms Authentication - context changing
      ... works via the cookie (generally, if you using the default web.config ... I have an ASP.NET application in my website in virtual folder A. ... I've implemented forms authentication (with application in folder ... I've also set up a redirection in IIS so that ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: Forms Authentication Name property
      ... you specify the name to be used for the authentication ... login page, then this can work. ... A cookie is saved by the BROWSER and ... The BROWSER chooses ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: SSL Forms Authentication Redirect - Problem Redirecting out of HTTPS
      ... allowing an authentication cookie to be passed over an HTTP ... My login script goes into SSL just fine. ...
      (microsoft.public.dotnet.framework.aspnet.security)