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. General Programming
  3. C#
  4. NullReferenceException

NullReferenceException

Scheduled Pinned Locked Moved C#
question
4 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.
  • A Offline
    A Offline
    AndreFratelli
    wrote on last edited by
    #1

    Why am I getting this exception here?

    if (Session["privilegios"] == null)

    Isn't this the way its supposed to check for null? Best regards

    Fratelli

    L 1 Reply Last reply
    0
    • A AndreFratelli

      Why am I getting this exception here?

      if (Session["privilegios"] == null)

      Isn't this the way its supposed to check for null? Best regards

      Fratelli

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Looks like Session itself is null Suggestion:

      if (Session == null || Session["privilegios"] == null)

      A 1 Reply Last reply
      0
      • L Lost User

        Looks like Session itself is null Suggestion:

        if (Session == null || Session["privilegios"] == null)

        A Offline
        A Offline
        AndreFratelli
        wrote on last edited by
        #3

        Yes, I already know what the problem is. For further reference: I had something like this

        [WebMethod(EnableSession = true)]
        public int method_1()
        {
        ...
        }

        [WebMethod]
        public int method_2()
        {
        // Code that calls metod_1
        }

        The thing is: If I call method_2, apperently, "Session" will still be null in method_1. I already have a previous post asking how to access "Session" variables in a non-WebMethod method. Regards

        Fratelli

        L 1 Reply Last reply
        0
        • A AndreFratelli

          Yes, I already know what the problem is. For further reference: I had something like this

          [WebMethod(EnableSession = true)]
          public int method_1()
          {
          ...
          }

          [WebMethod]
          public int method_2()
          {
          // Code that calls metod_1
          }

          The thing is: If I call method_2, apperently, "Session" will still be null in method_1. I already have a previous post asking how to access "Session" variables in a non-WebMethod method. Regards

          Fratelli

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Ok Now I know less than I thought I did, I don't know anything about web methods (until now I didn't even know they existed)

          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