FormAuthenticate.RedirectFromLoginPage

From: CW (a)
Date: 03/22/04

  • Next message: News: "Forms authentication problems"
    Date: Mon, 22 Mar 2004 16:18:13 +1100
    
    

    I am complete new to ASP.Net and still trying to find my way around, and all
    help is appreciated.

    I am using FormAuthenication to secure a web application I am building.
    Every pages (barring a few expecptions) are secured by using Authentication
    and Authorization tag in web.config.

    My problem is that I need to differentiate between administrator and normal
    user. The approach I have taken is that when a user attempts to access a
    page requiring administrative rights, I would first check whether user has
    admin right or not (by calling stored proc on a back end database) in the
    page load event of the page requiring administrative rights. If the user
    does not have the requisite right, I would use response.redirect
    (login.aspx) to direct the user back to the login back in the page load
    event.

    However, when the user attempts to log on, and my code calls
    FormsAuthentication.RedirectFromLoginPage(loginId, false) method where
    loginID is retrieved from back end database, I get the following error:

    Exception Details: System.Web.HttpException: Server cannot modify cookies
    after HTTP headers have been sent.

    Source Error:

    Line 59: 'End if
    Line 60:
    Line 61: FormsAuthentication.RedirectFromLoginPage(loginId,
    false)
    Line 62:
    Line 63: Else

    Any idea what is happening there? Note that RedirectFromLoginpage may have
    already been called when the user first enters the site (as the entire site
    is secured). However, the user might have logged on using a login without
    administrative priviledge. Thus, when they attempt to access pages requiring
    administrative rights, my code redirect them to the login page again (so
    that hopefully they'd log in with an id associated with administrative
    rights). My guess is that the problem is due to calling
    RedirectFromLoginPage again when authentication cookie has already been set
    within the same session.

    Anyway, all help appreciated.

    thanks in advance

    CW


  • Next message: News: "Forms authentication problems"

    Relevant Pages

    • Re: Finding REALLY hidden files?
      ... Do you have full administrative rights for the login ... I'm certainly logging into an administrator account. ... I use Win2K on NTFS and it has various security settings for all files and folders. ... Search for your login name and give yourself full permissions and ownership of the file/folder. ...
      (rec.video.desktop)
    • Re: Only administrator can login ??
      ... that's why I suggested to try login via ftp.exe first.... ... Bernard Cheah ... or the user doesn't has the administrative rights, ... using IE to access the FTP server. ...
      (microsoft.public.inetserver.iis.ftp)
    • Re: default screen server
      ... I think /Profiles/Default User/ will be always in use by the user that login ... > administrative rights to do the copy. ... > Dave Patrick ....Please no email replies - reply in newsgroup. ... > Microsoft MVP [Windows] ...
      (microsoft.public.win2000.general)
    • Re: remote access question
      ... administrative rights. ... to access Exchange, your users need to be using: ... > I can login with the administrator account, ... > login with any of the user accounts. ...
      (microsoft.public.windows.server.sbs)