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. Security

Security

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netsecurityregex
5 Posts 3 Posters 1 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hello, I have written a logon page for my site and it seems to work. Users can only authenticate if their usernames and passwords match in my web.config file under the credentials tag. How can I then stop users accessing my other pages? In Classic ASP I would set a session variable to indicate if the user was authenticated. Is it still the same in ASP.NET or is there a better way now? :)

    A T 2 Replies Last reply
    0
    • A Anonymous

      Hello, I have written a logon page for my site and it seems to work. Users can only authenticate if their usernames and passwords match in my web.config file under the credentials tag. How can I then stop users accessing my other pages? In Classic ASP I would set a session variable to indicate if the user was authenticated. Is it still the same in ASP.NET or is there a better way now? :)

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      The documentation says the Session object is "intrinsic" and should work as in Classic ASP. I have put the session test in the OnPageLoad event handler - is this right? Where are any examples? I cannot find any! When I try to use it I get an error: CS0118: 'System.Web.UI.Page.Session' denotes a 'property' where a 'method' was expected How can I use the Session object in C#? Is this not right?

      void OnPageLoad(Object sender, EventArgs e)
      {
      if (!Session("bValid"))
      {
      Response.Redirect("frmLogin.aspx");
      }
      }

      J 1 Reply Last reply
      0
      • A Anonymous

        The documentation says the Session object is "intrinsic" and should work as in Classic ASP. I have put the session test in the OnPageLoad event handler - is this right? Where are any examples? I cannot find any! When I try to use it I get an error: CS0118: 'System.Web.UI.Page.Session' denotes a 'property' where a 'method' was expected How can I use the Session object in C#? Is this not right?

        void OnPageLoad(Object sender, EventArgs e)
        {
        if (!Session("bValid"))
        {
        Response.Redirect("frmLogin.aspx");
        }
        }

        J Offline
        J Offline
        Jon Sagara
        wrote on last edited by
        #3

        Anonymous wrote: How can I use the Session object in C#? Like this:

        Session["bValid"]

        For more information about ASP.NET authentication & authorization, see this online book. ETA: Oops... this online book[^] :-O Jon Sagara As you may presently yourself be fully made aware of, my grammar sucks. Sagara.org | Blog | My Articles J.O.N.S.A.G.A.R.A.: Journeying Operational Neohuman Skilled in Assassination, Galactic Analysis and Rational Astrophysics -- modified at 13:51 Tuesday 20th September, 2005

        A 1 Reply Last reply
        0
        • J Jon Sagara

          Anonymous wrote: How can I use the Session object in C#? Like this:

          Session["bValid"]

          For more information about ASP.NET authentication & authorization, see this online book. ETA: Oops... this online book[^] :-O Jon Sagara As you may presently yourself be fully made aware of, my grammar sucks. Sagara.org | Blog | My Articles J.O.N.S.A.G.A.R.A.: Journeying Operational Neohuman Skilled in Assassination, Galactic Analysis and Rational Astrophysics -- modified at 13:51 Tuesday 20th September, 2005

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          Thanks. I finally figured out the Session requiring square brackets after eventually finding it somewhere. Thanks for the book link too :cool:

          1 Reply Last reply
          0
          • A Anonymous

            Hello, I have written a logon page for my site and it seems to work. Users can only authenticate if their usernames and passwords match in my web.config file under the credentials tag. How can I then stop users accessing my other pages? In Classic ASP I would set a session variable to indicate if the user was authenticated. Is it still the same in ASP.NET or is there a better way now? :)

            T Offline
            T Offline
            thowra
            wrote on last edited by
            #5

            If you're using ASP.NET authentication you can do a check on each "protected" page to see if the user is authenticated, by examining the User.Identity.IsAuthenticated property. Evil cannot be conquered in the world... It can only be resisted within oneself.

            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