is the best way - postback login change

Discussion in 'ASP .Net' started by kal, Jun 16, 2007.

  1. kal

    kal Guest

    Hi,

    I have a login control in a master frame.
    In the page_load event handler i check
    to see if a user is logged in or not and then
    display their name or the login control.

    This runs every time a new page is loaded.
    Is this an efficient way to do this?

    even if i use !ispostback it runs because
    navigation isnt posting back.

    Thanks for advice

    Kal
    kal, Jun 16, 2007
    #1
    1. Advertising

  2. "kal" <> wrote in message
    news:6jOci.278$...
    > Hi,
    >
    > I have a login control in a master frame.
    > In the page_load event handler i check
    > to see if a user is logged in or not and then
    > display their name or the login control.
    >
    > This runs every time a new page is loaded.
    > Is this an efficient way to do this?
    >
    > even if i use !ispostback it runs because
    > navigation isnt posting back.
    >
    > Thanks for advice
    >
    > Kal
    >



    try putting your code in the global.asax file use the session onstart sub

    if loggedIn <> true then
    response.redirect("login.aspx")
    end if

    now in your login page include

    Session.Abandon()


    Now if any one tries to navigate to one of your pages without being logged
    in they will be directed to the login page, if they are logged in they will
    not be tested again
    ThatsIT.net.au, Jun 16, 2007
    #2
    1. Advertising

  3. Hi,

    If you are using .NET 2.0 framework, have a look at LoginView Control:

    <asp:LoginView ID="LoginView1" Runat="server">
    <AnonymousTemplate>
    User is not logged in.<br />
    Add <asp:Login /> control here.
    </AnonymousTemplate>
    <LoggedInTemplate>
    User is logged in.<br />
    </LoggedInTemplate>
    </asp:LoginView>

    For more info:
    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.loginview.aspx

    Regards,
    Mital
    http://mital.kakaiya.com


    On Jun 16, 7:45 pm, "kal" <> wrote:
    > Hi,
    >
    > I have a login control in a master frame.
    > In the page_load event handler i check
    > to see if a user is logged in or not and then
    > display their name or the login control.
    >
    > This runs every time a new page is loaded.
    > Is this an efficient way to do this?
    >
    > even if i use !ispostback it runs because
    > navigation isnt posting back.
    >
    > Thanks for advice
    >
    > Kal
    Mital Kakaiya, Jun 17, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William F. Robertson, Jr.
    Replies:
    0
    Views:
    427
    William F. Robertson, Jr.
    Jul 2, 2003
  2. Ashraf Fouad
    Replies:
    0
    Views:
    348
    Ashraf Fouad
    May 22, 2004
  3. JJ
    Replies:
    1
    Views:
    380
  4. pj
    Replies:
    2
    Views:
    1,915
  5. Ed Cayce
    Replies:
    0
    Views:
    898
    Ed Cayce
    Aug 8, 2009
Loading...

Share This Page