Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. securing web pages using forms authentication

securing web pages using forms authentication

Scheduled Pinned Locked Moved ASP.NET
helpasp-netsecuritytutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pradip Kishore
    wrote on last edited by
    #1

    i have two web pages(login.aspx and account.aspx)i want to secure my account.aspx from unauthorised access.i used forms authentication as modified the web.config as follows: in the login button click event the codes are as follows: if username.text="pradip" and password.text="pkc" then FormsAuthentication.RedirectFromLoginPage(username.text,false) else labelmsg.text="invalid user name or password" now my problem is that when ever i am directly accesing accout.aspx(without logging in),it is not automatically redirecting to login.aspx.. suoopse i have 10 webforms in my project out of which i want to make 5 web forms secure so that if any unauthorised user wants to access them,they will be automatically redirected to login.aspx ..how can i do this(i think that i have to check the cookie value "AuthCookie" in the page load event of the secure pages..but i dont know how to do it.. if i write request.cookies("AuthCookie").value is nothing then response.redirect("login.aspx").. in the page load events of the secure pages then also it is not redirecting to login.aspx..plz help me out this..its urgent .. thanks in advance

    pradip kishore

    R 1 Reply Last reply
    0
    • P Pradip Kishore

      i have two web pages(login.aspx and account.aspx)i want to secure my account.aspx from unauthorised access.i used forms authentication as modified the web.config as follows: in the login button click event the codes are as follows: if username.text="pradip" and password.text="pkc" then FormsAuthentication.RedirectFromLoginPage(username.text,false) else labelmsg.text="invalid user name or password" now my problem is that when ever i am directly accesing accout.aspx(without logging in),it is not automatically redirecting to login.aspx.. suoopse i have 10 webforms in my project out of which i want to make 5 web forms secure so that if any unauthorised user wants to access them,they will be automatically redirected to login.aspx ..how can i do this(i think that i have to check the cookie value "AuthCookie" in the page load event of the secure pages..but i dont know how to do it.. if i write request.cookies("AuthCookie").value is nothing then response.redirect("login.aspx").. in the page load events of the secure pages then also it is not redirecting to login.aspx..plz help me out this..its urgent .. thanks in advance

      pradip kishore

      R Offline
      R Offline
      RedhaDev
      wrote on last edited by
      #2

      I prefer using Session variables rather than cookies because some users disable cookies of their navigators. It's so easy to use !! 1. Authenticate event in the login page : protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if ((username.text="pradip") && (password.text="pkc" )) Session["Authenticated"] = "Ok"; } 2. on_Load event of every Secured page : if (Session["Authenticated"].ToString() != "Ok") RedirectToLognPage().....

      The novice.

      P 1 Reply Last reply
      0
      • R RedhaDev

        I prefer using Session variables rather than cookies because some users disable cookies of their navigators. It's so easy to use !! 1. Authenticate event in the login page : protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if ((username.text="pradip") && (password.text="pkc" )) Session["Authenticated"] = "Ok"; } 2. on_Load event of every Secured page : if (Session["Authenticated"].ToString() != "Ok") RedirectToLognPage().....

        The novice.

        P Offline
        P Offline
        Pradip Kishore
        wrote on last edited by
        #3

        hi novice thanks for your vital support do i have to use the forms authentication..or simple i set the cookie after the validation of the user credentials in the login form..? if i dont use the forms authentication,then how i can make the user to sign out while pressing sign out button.. please replay back soon.. thanks in advance

        pradip kishore

        R 1 Reply Last reply
        0
        • P Pradip Kishore

          hi novice thanks for your vital support do i have to use the forms authentication..or simple i set the cookie after the validation of the user credentials in the login form..? if i dont use the forms authentication,then how i can make the user to sign out while pressing sign out button.. please replay back soon.. thanks in advance

          pradip kishore

          R Offline
          R Offline
          RedhaDev
          wrote on last edited by
          #4

          In my example I used the authentication form of Visual Studio and its "Authenticate" event. There's no use of cookies.

          The novice.

          P 1 Reply Last reply
          0
          • R RedhaDev

            In my example I used the authentication form of Visual Studio and its "Authenticate" event. There's no use of cookies.

            The novice.

            P Offline
            P Offline
            Pradip Kishore
            wrote on last edited by
            #5

            from where would i get the authenticate form..is it built in or i have to design one..if built in..will you please tell me how to incorporate it into my project..??? please reply back soon thanks in advance..

            pradip kishore

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups