C# - Object Losing Reference When Assigning It To Session?

Oct 14, 2010

I am facing a very strange issue. I get an error Object Reference Not set to instance of object on the server while the code runs fine on my dev machine. The strange part is the line number where the code is throwing error (as appears in the Stack trace)

DemoUser demoUser = new DemoUser();
if (!Request.QueryString.AllKeys.Contains("name"))
{
playerName = usr.NinjaName;
demoUser.Email = usr.UserEmail;
demoUser.UserPicture = usr.UserPicture;
}
else
{
playerName = Request.QueryString["name"];
demoUser.Email = String.Empty;
demoUser.UserPicture = "http://graph.facebook.com/1/picture";
}
demoUser.EntryDateTime = DateTime.Now;
demoUser.Name = playerName;
Session["DemoUser"] = demoUser;
imgPlayer.ImageUrl = demoUser.UserPicture; // This is throwing error.

If that line is throwing error then the demoUser object is getting lost when I assign it to Session. Is that right?

View 2 Replies


Similar Messages:

State Management :: Large Session Object Losing Value?

May 10, 2010

I have a asp.net application where I am saving off into session the user privilege information. From a grid I am bring up a new window by using the window.open. It seems that it is whiping out the values in session. A temporary bandaid I have placed on it is to recall the database if the value is nothing to reset the user object. I have found all over the internet that this is an issue with the window.open in IE 7 and IE 8. Has anyone else run into this and able to actually fix it?

View 4 Replies

Web Forms :: Session Ended - But Server Error/ Object Reference Not Set To An Instance Of Object?

Nov 15, 2010

In the VS2005 environment, when I test my session to make sure the page redirects to the main page (itself) if the session is null, it works. There is no error.

The function I use for this is:

[code]....

However, when it is in the production environment in IIS 6.0, when the session has timed out, and I then do a postback by doing some slider control, I see the page reload but immediately thereafter, it throws a Server Error exception of : Object reference not set to an instance of object.

Looking at the stack trace, the event occured:

AJAXEnabledWebApplication1._Default.Slider1_TextChanged(Object sender, EventArgs e)

however, why is it that the Slider1_TextChanged event fired even even after during page_load, the page was told to do a response.direct ?? shouldn't the entire page have gone through a full-page refresh life cycle ? why did it continue on to attempt to raise the Slider1_TextChanged event?

View 1 Replies

Web Forms :: Error When Converting Session To String / Object Reference Not Set To Instance Of Object

May 7, 2015

I am getting object refernce error at line:if (Session["Tax"].ToString() == "9")

protected void Page_Load(object sender, EventArgs e)
{
if (Session["Tax"].ToString() == "9")
{
lblTax.Text = Session["Tax"].ToString();
}
else
{
lblTax.Text = "0";
}
}

Is anything wrong I have done?

View 1 Replies

Session - Object Reference Not Set To An Instance Of An Object?

Jun 19, 2010

I have this problem when trying to read a session in another asp.net page.

Object reference not set to an instance of an object.

If Session("cne").Equals("") Then Response.Redirect("Default.aspx")End If

I'm setting the session in the Default page with this code :

Session("cne") = cne.Text

View 1 Replies

Error "Object Reference Not Set To An Instance Of An Object" With Using Session

Dec 17, 2010

I am getting thid error Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error:

Line 18:
Line 19: <%&nbsp;
Line&nbsp;20:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string&nbsp;thedate&nbsp;=&nbsp;Session["indate"].ToString();////;;;;????
Line&nbsp;21:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write("Starting&nbsp;SAS");
Line&nbsp;22:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try &nbsp; &nbsp;
Source&nbsp;File:&nbsp;c:Documents&nbsp;and&nbsp;SettingsAdministratorMy&nbsp;DocumentsVisual&nbsp;Studio&nbsp;2008WebSitesWebSite1SASrun.aspx&nbsp;&nbsp; &nbsp;
upload.aspx
<%@&nbsp;Page&nbsp;language="c#"Debug&nbsp;=true&nbsp;Codebehind="upload.aspx.cs"&nbsp;AutoEventWireup="false"&nbsp;
Inherits="Stardeveloper.UploadAccess.UploadForm"&nbsp;%>
<script runat="server">
void Button2_Click(object sender, EventArgs e)
{
Session["indate"] = Request["txtDate"];
Response.Redirect("SASrun.aspx");
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
</head>
<body>
<body style="background:#80B584">
<form runat=server>
<a href="default.aspx"><b>Main Page</b></a> · Upload Files
<div id="message" runat="server" />
<table align="left" border="0" cellspacing="0" cellpadding="3">
<p style="font-family:arial;color:White;font-size:20px;">Upload new files.</p>
<tr><td><b>MTMDetailed:</b></td><td><input type="file" class="stdInput" name="uploaded_file1"></td></tr>
<tr><td><b>File TRI_FP:</b></td><td><input type="file" class="stdInput" name="uploaded_file2"></td></tr>
<tr><td><b>indate :</b></td><td><input type="text"id="txtDate" name="inputdate"/></td></tr>
<tr><td align="right"><input type="submit" value="Submit"></td></tr>
<asp:Button id="Button2" runat="server" Text="Submit" onClick="Button2_Click" />
</table>
</form>
</body>
</html>

This is part of the code where error is coming from................

View 1 Replies

State Management :: Session Time-out : Object Reference Not Set To An Instance?

Oct 26, 2010

I noticed that when i am debugging my web application in Visual Studio 2005 using IIS, after about 10-15 minutes of inactivity, when I do something in the application such as a postback, I get an immediate error saying: "object reference not set to an instance" and my code breaks somewhere.Is my assumption correct that this is because my session has timed out? ( i do have a 15 minute default session time)my next question is, how do I display or set a way so that like many other pages, when the session has expired, a message will say: "This page must be refreshed" or "Your session has expired, click okay to refresh page" and start over again?

View 1 Replies

Web Forms :: Object Reference Not Set To An Instance Of An Object Error When Remove Reference To Site Master Page

Sep 30, 2010

in my default.aspx page i have a dropdown List and a textbox with a submit button below that there are 2 listbox... and the dropdown list holds the names of the listbox

my logic here is to select an item from the dropdown list and put some text in the text box and submit the form which will add an item to the listbox selected.. but when i do this i get an error saying Object reference not set to an instance of an object. i tried to figure out the problem and found that when i remove the reference to the Site Master Page it works fine and when i undo and apply my reference back to the Site Master Page i get the same error.

[Code]....

View 2 Replies

C# - Session Variable Assigned To Data Table And Create Object Reference?

Jan 13, 2010

----> I have datatable which is passing to another page in session variable.
----> Now on another page i take the session variable into datatable.

datatable ds_table = new datatable();
ds_table = (datatable)session["table_value"];

----> so problem, is that , when i filtering some rows from ds_table . that taking effect in the session variable. if some rows deleted from ds_table. then it is also deleted from session variable.

----> so, anyone tell me why is this going to happene?

View 3 Replies

Web Forms :: Gridview, Paging And Object Reference Not Set; Error - Object Reference Not Set

Jan 21, 2010

I am using grid view as mentioned below, it is giving me error "object reference not set", but if comment allowpaging and pagesize lines, it works. let me know whats wrong I am doing?

[Code]....

[Code]....

View 2 Replies

Web Forms :: Page Losing Reference To Dynamicallly Created Tablerows?

Jan 6, 2010

I'm new to the asp.net/vb.net world and have stumbled across a problem.I have a page that has a gridview. When the user clicks on a link in the grid a modal popup is shown (using the AJAX modalpopupextender).On this pop up is a treeview that the user can then select some child nodes.When they click a button a table is dynamically populated with the list from the selected treeview nodes.The user can then add detail in this table comments etc and then should be able to click on a save button. This will then fire the event to loop through the table and insert these records into a database.The problem is that when the Save button is clicked the page seems to have lost all reference to the fact that there are dynamically created rows in the table even though there are a number of rows that you can still see displayed on the page. Even the table.rows.count shows 1 at this point!

View 3 Replies

WCF / ASMX :: Null Reference Error When Assigning A Value Into Custom Type Array Via WSDL

Mar 2, 2011

I have a WSDL: [URL] (I have changed address location).

My code is for accessing data from SAP via WSDL; bind that to .NET control as well as sending data from .NET control to SAP via same WSDL.

The code is like below:

[Code]....

On the other way, When I am binding data with .net control at from load event then there is a no problem.

The code is like below:

[Code]....

View 9 Replies

MVC :: Reference To A Non-shared Member Requires An Object Reference In Code Generated?

Oct 4, 2010

I am working on converting a project from C# to VB and am facing this weird issue. 1 page cannot compile and I get the reference error, but the weird thing is that the compiler shows the error as coming from ASP.NET generated code. Visual Studio shows me that error is coming from my ASPX page. I cannot seem to figure out why or where this error is occuring. Also if I take the inherits attribute out I don't get the compilation error. The code in aspx page is below:

[Code]....

View 18 Replies

DataSource Controls :: Reference To A Non-shared Member Requires An Object Reference

Apr 22, 2010

I am using VS2005, and a newbie at table adapters, DAL & BLL. I have a single dataset (in DAL) and 2 classes (in BLL) named Class1.vb and Class2.vb.

When I try to call a function from Class1 within Class2 I get the error "Reference to a non-shared member requires an object reference".

Here is a sketch of my code structure:

[Code]....

View 3 Replies

C# - Losing The Session After The Postback?

Sep 1, 2010

I have been using session variables in my asp.net application for passing the next property:

[DefaultValue(true)]
public bool IsModificationMode
{
get
{
return (bool)Session["ModificationMode"];
}
set { Session["ModificationMode"] = value; }
}

In the PageLoad, I set it's value.

Now after the Postback, I am losing it's value having a a NullReferenceException

View 4 Replies

State Management :: Error Like: Object Reference Not Set To An Instance Of Reference?

Aug 25, 2010

I have a url like this:

http://www.somepage.com/main.aspx. In this page, when I click on a link it takes me to a page
http://www.somepage.com/cental.aspx?cid=200. So in the cental.aspx.cs page I did the following in the page load:

if(request.querystring["comp"].tostring() != null)
{
//do some thing [code].....

So I got an error like: object reference not set to an instance of reference.My problem is, I am using the same page. So when I go from some page, I will have "comp". but other times not. So when there is no "comp", how do I handle it in request.querystring?

View 3 Replies

How To Save Web Config Without Losing Session

Jun 29, 2010

I thought about saving all sessions variables to hiddens and then resaving those values back into session after I changed the web config..but there has GOT to be another way.

View 1 Replies

Reference To A Non-shared Member Requires An Object Reference?

Oct 8, 2010

I do not receive this error when I open my website application in vs 2005. When I open in vs 2008, I get this error. What gives?

These lines are underlined in blue:

[Code]....

Businesslogic area is imported into each of 3 pages with this line.

View 9 Replies

Forms Data Controls :: Assigning Repeater Value Using Object Properties?

Dec 25, 2010

I have a repeater control which looks like so: (Trimed it to show the essentials)

[Code]....

And i have a class which looks like so:

[Code]....

Is there anyways i can use the class properties to populate the repeater control? Probably modify the class or something?

View 1 Replies

About Session Variables Losing Its Values Before Time Out?

Jun 14, 2010

I've got some ASP pages where the session variable values get blown away BEFORE the session times out. I can't understand it. For example: if a user logs into my ASP app using his password which is stored in a session variable, it will be fully accessible for a few minutes and then all of a sudden.....Wham session variable with password value is gone. And the session timeout is far from expired. The session variable is not being touched in any way after it gets initialized with a value.

View 3 Replies

State Management :: Certain Users Losing Certain Session Variables?

Mar 14, 2011

There are a couple of user's experiences session variable loss after they've clicked a confirm button and their information is email via a relay hosting server. Below, I commented exactly where the session variables get lost.

What could be causing the session variable loss? So far, this only happens to a few users.

Part of the email that gets sent out:

[Code]....

Web config file:

[Code]....

View 4 Replies

Security :: Losing Session When Switching Between HTTPS And HTTP?

Jan 28, 2010

I am using partially secured pages ( SSL). Now the problem is when I am switching between HTTPS and HTTP, I am losing my session. I tried storing session in Sql Server Database, its still not working. I am using just ONE web server and all pages are in single application.I am using Sql server 2008 ,IIS 7.0, C#.Net 3.5 I created a self signed test certificate to test my application.

I understand that I am losing my session because my urls are changing with https and http but there has to be someway to overcome this problem. I dont want to put unnecessary load on pages which do not have sensitive data by using https.

View 1 Replies

Asp - Losing Session Variables - What Exception Might Cause Sessions To Be Lost

Oct 1, 2010

I have health monitoring enabled on a production system (asp.net webforms .net 4) and I see that there's a lot of errors being sent to me indicating that a session variable has been lost.(I am trying to attach something out of session state to a entity framework data context and get a "Value cannot be null, parameter n ame entity" error). So somehow the session variable now contains null and not an object. Interestingly we have the same application deployed on two separate servers - one DMZ server for external users and one internal server for internal users. Both of these applications on two different servers seem to have the same problem.

Health Monitoring is also monitoring lifetime events and I can see from this that we do not have something like IIS recycling, config changes, changes to bin folder, recompilations etc, occuring. I've read this page: [URL] I can confirm that it's not a Response.Redirect problem because that's not happening - this is an online application form - it puts an object in session state on page_load and there's a multiview - when "next" is pressed, the object comes out of session state, is attached to the data context, changes are made from the web form and the datacontext updated. So there's no response.redirect happening.

I can also confirm the details in "Update 1" and "Update 2" from that link are not relevant to me - there is only 1 worker process running in the application pool and the server name or web address do not contain underscores. I also persued the possibility of session timeouts occuring but they should be handled by other code which is running to detect session timeouts (see: [URL]) which I have tested over and over - Part of the problem is I just cannot reproduce this error myself.......................

View 1 Replies

Visual Studio :: Losing Session When Debugging After Redirect?

Mar 14, 2011

OS: Windows 7

VS: VS 2010 Pro SP1 - IIS Express

I am debugging my project, the first page is a login page which I login and I can see from debug that the session is being set, after the redirect to the homepage the session seems to be lost and I am taken back to the login page.

If I run outside of VS on our sandbox or production server the login works fine. It only seems to be my machine w/ VS that does not like the sessions.

View 2 Replies

DataSource Controls :: Simple Login Form - Object Reference Not Set To An Instance Of An Object?

Apr 20, 2010

im tryin to create a login form.

and am receiving the following error:

Object reference not set to an instance of an object

[Code]....

and heres my aspx page:

[Code]....

Stored procedure:

[Code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved