Forms authentication & frames

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • G-Fit

    #1

    Forms authentication & frames

    Hello group,

    I use Forms Authentication in an intranet website. This website has a
    framed default.aspx page : one left frame for a menu, one right frame for
    the content. The menu depends on the authentication (i.e. each user won't
    see the same menu) : for this, I use another cookie (let's call it the
    user_id cookie).
    If a user identifies him/herself, closes the browser, and comes back
    after the authentication cookie has expired, he is redirected to the login
    page. Fine.
    On session start, I check if the user_id cookie exists and if it is not
    expired (without this the menu would fail to build). Otherwise, I do a
    FormsAuthentica tion.SignOut(). And here comes the problem : the login page
    appears in the left frame, instead of taking all the page. My login page
    being larger than the frame, the result is awful.
    Any idea on what I could do to force the login page to appear 'normally'
    ?

    Karine Proot
    G-Fit


  • G-Fit

    #2
    Re: Forms authentication & frames

    Some code provided in case it can help understand what I'm doing :

    in Web.config :
    <authenticati on mode="Forms">

    <forms name=".FaF_logi n" loginUrl="login .aspx" protection="All " timeout="30"
    path="/" />

    </authentication>



    in my login.aspx codebehind :

    HttpCookie cookie = new HttpCookie(".Fa F_userid");

    cookie.Value = reader["CTC_ID"].ToString();

    cookie.Expires = DateTime.Now.Ad dHours(8);

    Response.Cookie s.Add(cookie);

    FormsAuthentica tion.RedirectFr omLoginPage (txtLogin.Text, true);


    Comment

    • Steven Cheng[MSFT]

      #3
      Re: Forms authentication &amp; frames

      Hi G-Fit,

      From your description, you are using the FormsAuthentica tion and the web
      application is frame based. When the user's authentcation token has expired
      and be redirected to the login page. The login page sometimes occur in the
      left frame rather than the top frame which maked the whole page very ugly.
      So you're wondering how to make the login page display in the top leve
      frame no matter what the original location it's located , yes?

      I've also occured such problem before and my solution is to use a client
      script block in the "login.aspx " page to detect whether the login page is
      at the top frame. And execute the script when at the client side's onload
      event. For example, in the login page we put the below function in <head>
      area:

      .....
      <script language="javas cript">
      function goTopFrame()
      {
      if(window != window.top)
      {
      window.top.loca tion.href = window.location .href;
      }
      }
      </script>
      </head>

      Then, use in the body's onload:

      <body onload="goTopFr ame()" >

      Thus, when the login page is loaded it'll detect whether it is located in
      the top window. if not, set the top window's location as the login page.
      How do you think of this?

      Regards,

      Steven Cheng
      Microsoft Online Support

      Get Secure! www.microsoft.com/security
      (This posting is provided "AS IS", with no warranties, and confers no
      rights.)

      Get Preview at ASP.NET whidbey
      http://msdn.microsoft.com/asp.net/whidbey/default.aspx

      Comment

      • G-Fit

        #4
        Re: Forms authentication &amp; frames

        Hi Steven,

        Thanks a lot for your solution, which works great. I'm sorry as this was not
        dotnet-related and only needed a bit of javascript, thank you for taking
        your time answering me.
        Karine

        "Steven Cheng[MSFT]" <v-schang@online.m icrosoft.com> a écrit dans le message
        de news:1g7IK4tGEH A.3436@cpmsftng xa06.phx.gbl...[color=blue]
        > Hi G-Fit,
        >
        > From your description, you are using the FormsAuthentica tion and the web
        > application is frame based. When the user's authentcation token has[/color]
        expired[color=blue]
        > and be redirected to the login page. The login page sometimes occur in the
        > left frame rather than the top frame which maked the whole page very ugly.
        > So you're wondering how to make the login page display in the top leve
        > frame no matter what the original location it's located , yes?
        >
        > I've also occured such problem before and my solution is to use a client
        > script block in the "login.aspx " page to detect whether the login page is
        > at the top frame. And execute the script when at the client side's onload
        > event. For example, in the login page we put the below function in <head>
        > area:
        >
        > ....
        > <script language="javas cript">
        > function goTopFrame()
        > {
        > if(window != window.top)
        > {
        > window.top.loca tion.href = window.location .href;
        > }
        > }
        > </script>
        > </head>
        >
        > Then, use in the body's onload:
        >
        > <body onload="goTopFr ame()" >
        >
        > Thus, when the login page is loaded it'll detect whether it is located in
        > the top window. if not, set the top window's location as the login page.
        > How do you think of this?
        >
        > Regards,
        >
        > Steven Cheng
        > Microsoft Online Support
        >
        > Get Secure! www.microsoft.com/security
        > (This posting is provided "AS IS", with no warranties, and confers no
        > rights.)
        >
        > Get Preview at ASP.NET whidbey
        > http://msdn.microsoft.com/asp.net/whidbey/default.aspx
        >[/color]


        Comment

        Working...