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. System.NullReferenceException: Object reference not set to an instance of an object.

System.NullReferenceException: Object reference not set to an instance of an object.

Scheduled Pinned Locked Moved ASP.NET
helpdesignquestion
2 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.
  • M Offline
    M Offline
    M Ambigai
    wrote on last edited by
    #1

    user.aspx.cs: public partial class user : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = Session["val"].ToString(); } } login.aspx.cs: if (reader["pword"].ToString() == pswd.ToString()) { Session["val"] = TXtLoginName.Text; Response.Redirect("User.aspx"); } Still "Object reference not set to an instance of an object" error occurs :confused: sir. can u please help me?

    C 1 Reply Last reply
    0
    • M M Ambigai

      user.aspx.cs: public partial class user : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = Session["val"].ToString(); } } login.aspx.cs: if (reader["pword"].ToString() == pswd.ToString()) { Session["val"] = TXtLoginName.Text; Response.Redirect("User.aspx"); } Still "Object reference not set to an instance of an object" error occurs :confused: sir. can u please help me?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Well, your code really sucks. You should not hard code session keys, you also should never check the session without first making sure the value is not null. You should step through in the debugger to try to work out if you are setting the session value, and why it's null on the other end. you should also not write code that returns the correct password, that's not secure.

      Christian Graus Driven to the arms of OSX by Vista.

      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