.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Fauzul Azmi
Asad Ali
Post New Web Links

Session Object not set to an instance.....

Posted By:      Posted Date: September 04, 2010    Points: 0   Category :ASP.Net
 
Hello all, Please tell me if I have made a mistake in the following code. It is part of a class that cycles through various conditions to return a value to aspx page. I get null exception when it hits the session variable. I even declared the session variable in global.asax, and thought that I was checking for null value correctly. Obviously I haven'tImports Microsoft.VisualBasic Imports System.Linq Imports System.Web Imports System.Web.Services Imports System.Web.HttpContext Public Class OrderNumber Public Shared Function GetOrderNumber() As String ' ''//Sets OrderNumber if it exists If Not HttpContext.Current.Request.QueryString("OrderNumber") Is Nothing Then Return CType(HttpContext.Current.Request.QueryString("OrderNumber"), String) ElseIf Not HttpContext.Current.Session("OrderNumber") Is Nothing Then Return CType(HttpContext.Current.Session("OrderNumber"), String) ElseIf Not FindExistingOrder() Is Nothing Then Return FindExistingOrder() Else : Return "" End If End Function   Thanks, I am pretty well stumped. Have a good evening.


View Complete Post


More Related Resource Links

Session time-out : object reference not set to an instance...

  

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?

thanks.


Set an instance Session object

  

Hi..

When im running unit testing no an action in the homecontroller i get the following error: 

"Test method WhatsForLunch.Tests.Controllers.HomeControllerTest.Test_Index threw exception: System.NullReferenceException: Object reference not set to an instance of an object."

I know what is causing the error, which is the Session object that i set false and null

 at application start and is further used to track user and hold user information when a user is logged in.

How do i set the object to an instance so that i can perfrom unit testing to the action??

 

 

thx in Advance


send data in class object from one page to another using session

  

hello everybody

now i hav stored all data like user name, data fatched from database of that user

and i stored that data and user name such as:

string strUserName="user name"

dataset ds =new dataset();// data of that user

now i wan yo send d whole data from my login page to user profile page

can anybody help me for that...................

and plz tell me that how much is this way is benifitial to send data from one page to another page

plz........kindly waiting for positive rply


Common session for different browser instance

  

Hello everyone,

I am working on a website which uses a common database shared by another 2-3 websites.  Now i am having a requirement that whenever a user clicks a link provided on another website and comes to my website and if the user is already logged in to my website then my website should not ask him to login again it should by pass the login page and show the next page.

Here the problem is i am not able to get the session objects in newly opened browser window even if the user is already logged in to my website in another browser window. I am not sure but i thing IE uses two different processes for two different browser instance and because of that i am not getting the session objects required.

Deos anyone have some idea on my problem.

Note: I can not ask the another website vendor to pass anything as a querystring.


VS2010 Silverlight 4 - Getting "Object reference not set to an instance of an object" when loading a

  
In Visual Studio 2010 I'm trying to use the Blacklight Controls (http://blacklight.codeplex.com/releases/view/37652) in my own project (and actually included the Blacklight.Controls project in my solution so that I could debug what was going on) and... after making all the XAML changes needed to incorporate the Blacklight navigation menu with my stuff in the innermost grid... everything compiled ok when doing a Build.  When I run it there's a reference to a resource dictionary in the XAML that fails with the object reference error above.  The XAML is as follows:       <UserControl.Resources>       <controls:ResourceDictionaryManager x:Key="ResourceDictionaryManager">       <controls:ResourceDictionaryManager.ResourceDictionaries>       <controls:ResourceDictionaryCollection>       <controls:ResourceDictionary Path="/Blacklight.Showcase;component/ResourceDictionaries/DavesGlossyControls.xaml">       <controls:ResourceDictionary.ResourceKeys>       <controls:ResourceKeyCollection>       <controls:ResourceKey ResourceName="GlossyBlackScrollViewer" />       </controls:ResourceKeyCollection>     &

session object security in asp.net 4

  
hi,So I'm developing a complicated solution where users need to register, on the web application. I'm not going to use asp.net forms authentication because it would be too complicated to make it work in my app. We do not have SSL, it doesnt need to be super secure but the only thing I am worried about is:When the user logins, he is authenticated, then his username is stored in an asp.net session object. Every protected page then check if there is a username, is there isn't he is redirected. Is this secure?Is there a way an attacker can manipulate a session object to have it store a valid username, which will fool the pages to think that user has logged in. Is there any way to make it slightly more secure without hitting too much on performance?All the options I see are all about forms authentication.Thanks so much

Can I dehydrate the Workflow object as well as the instance?

  
Hiya All Can I dehydrate the workflow object (i.e. not an instanciation of it) into SQLServer?  I want to save all versions created of a workflow so that I can chose to instanciate the workflow from any of the previous versions if I need to. This is due to a compliancy issue - being able to reconstruct the data created by a previous version of a workflow to prove accuracy. ThanksMichelle x

reference not set to an instance of an object.

  
Hi friends,I got this error. This application for  delete  multiple record in gridview using Check Box.Please verify it. I tried before one application, that one finally worked,That application also error occurred, but after some time it execute(automatic I didnt do anything) correctly,Please tell me why this type of error occurred.  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 153: if (chkdelete != null) Line 154: { Line 155: chkall.Checked = array.Contains(grideviewsasmple.DataKeys[i].Value); Line 156: Line 157: if (!chkdelete.Checked) Source File: c:\Inetpub\wwwroot\AdditionUpdate\Default.aspx.cs    Line: 155

Object Reference not set to an instance of an object

  
Hi All,While using listview to upload images I get the error message. "Object Reference not set to an instance of an object".Gallery.aspx is suppose to call ManagePhotoAlbum.aspxError generatedLine 5: Protected Sub LinqDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles LinqDataSource1.Inserted Line 6: Dim myPhotoAlbum As PhotoAlbum = CType(e.Result, PhotoAlbum) Line 7: Response.Redirect(String.Format("ManagePhotoAlbum.aspx?PhotoAlbumId={0}", _ Line 8: myPhotoAlbum.Id.ToString())) Line 9: End SubCode Behind Gallery.aspx.vbPartial Class Photo_Gallery    Inherits System.Web.UI.Page    Protected Sub LinqDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles LinqDataSource1.Inserted        Dim myPhotoAlbum As PhotoAlbum = CType(e.Result, PhotoAlbum)        Response.Redirect(String.Format("ManagePhotoAlbum.aspx?PhotoAlbumId={0}", _            myPhotoAlbum.Id.ToString()))    End Sub    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load    End S

Object reference not set to an instance of an object.

  
This one has been killing me for 2 days now, and it should be so simple.I have a button on a page with an onClick that calls a web service.  I get the above error (on Line 938, Sys.WebForms.PageRequestManagerServerErrorException) as soon as the button is clicked.  The error seems to occur the second that the service is called - I have verified that every step of  the client-side code works and does not contain null values.  When remote debugging, the exception hits as soon as it jumps over to the web service's source code, an indication that the reference to the server itself is also valid.The code: (bad spelling and formatting not mine... I inherited this and have been cleaning it up as I go)'btnClick event - removed the log-writing lines for clarity's sake Private Sub btnSendCIS_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendCIS.Click Dim dt As DataTable Dim retr As String = "" dt = createOrderTable() Dim client As New ProdEndpoints.CISPRODUCTIONClient() retr = client.CompleteOrders(dt) client.Close() tmRecive.Interval = tickinterval getallrecive() End Sub 'createOrderTable - creates the dt that is sent to the service, also with log-writing lines removed. verified this is not returned Null as the log-writing includes pulling ou

Null Reference Exception was not handled by user Object Reference not set to instance of an object

  
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Security.Principal;using System.Data;using System.Data.SqlClient;using System.Windows;using System.Collections; public partial class Default2 : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {     }    private bool tableCopied = false;    private DataTable originalDataTable;     protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)    {         if (e.Row.RowType == DataControlRowType.DataRow)        {            //string sValue = e.Row.Cells[3].Text;             if (!tableCopied)            {                originalDataTable = ((System.Data.DataRowView)e.Row.DataItem).Row.Table.Copy();                ViewState["originalDataTable"] = originalDataTable;      &nbs

Object reference not set to an instance of an object.

  
can anybody help me with this error??the error occurs in the first line of the if statement...i really dont know how to fix this problem.. please help..Dim GW1 As new GridView            GW1 = CType(Me.LoginView1.FindControl("GridView1"), GridView)            If GW1.PageCount < 1 Then                lblFromDept.Visible = True                ddlFromDept.Visible = True                SelectedFromDept.Visible = False                btnOK.Visible = True            Else                lblFromDept.Visible = False                ddlFromDept.Visible = False                SelectedFromDept.Visible = False                btn

Object reference not set to an instance of an object.

  
When  can debugg the code it will give the error "Object reference not set to an instance of an object.". The code is--     using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using SMC.AlphaAccounting.EntryControls; using SMC.AlphaAccounting.PlugIns; using SMC.PlugInContracts; using SMC.BusinessObjects; using SMC.Utils; using SMC; using SMC.AlphaAccounting; using SMC.AlphaAccounting.DataEntry; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinMaskedEdit; using Infragistics.Win.UltraWinToolbars; namespace WindowsApplication3 {     public partial class FormCountry : SmcDataEntry     {         private boGlChart boLocalGlChart;         private boVendors boLocalVendors;         public FormCountry()         {             InitializeComponent();             this.ultraNumericUniqueID.KeyDown += new KeyEventHandler(ultraNumericUniqueID_KeyDown);             this.ultraNumericUniqueID.KeyPress &

Object reference not set to an instance of an object.

  
Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)         Dim CUW1 As New CreateUserWizard         CUW1 = CType(Me.LoginView1.FindControl("CreateUserWizard1"), CreateUserWizard)         Dim p As ProfileCommon = DirectCast(ProfileCommon.Create(CUW1.UserName, True), ProfileCommon)         p.SelectFromDept = DirectCast(CUW1.CreateUserStep.ContentTemplateContainer.FindControl("ddlSelectFromDept"), DropDownList).SelectedValue         p.Save()     End Subanybody can help me with this error?? that error occurs in the p.SelectFromDept line...Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)        Dim CUW1 As New CreateUserWizard        CUW1 = CType(Me.LoginView1.FindControl("CreateUserWizard1"), CreateUserWizard)        Dim p As ProfileCommon = DirectCast(ProfileCommon.Create(CUW1.UserName, True), ProfileCommon)        p.SelectFromDept = DirectCast(CUW1.CreateUserStep.ContentTemplateContainer.FindControl("ddlSelectFromDept"), DropDownList).SelectedValue        p.Save()    End S

"Object reference not set to an instance of an object."

  
Working in Visual Web Developer 2008 Express Edition, attempting to configure data source (SqlDataSource),  able to include server name: (local)\sqlexpress and the "Test Connection" is successful.  However, when I try to make a new database (or load one of the samples), I keep getting an alert: "Object reference not set to an instance of an object."  I've posted in this forum under "Data Access: Sql Server, Sql Server Express..." with a response to remove and then reinstall VWD and SQL Express.  Thus, I've removed and reinstalled Sql Server 2008.  I tried to remove then reinstall VWD 2008 Express with "Windows Install Clean Up" and "Add / Remove Programs", but in Add/ Remove Programs, it just tried to reinstall without removing then stopped halfway and prompted me to insert a disc (which I don't have since it was an online download).  Not sure what is going on behind the scenes.  Don't know what the problem is as this was never an issue in VWD 2005 Express Edition. Does the problem involve Visual Web Developer 2008 Express Edition or SQL Server 2008?  Any suggestions on removing and then reinstalling VWD 2008 Express?  I feel like I'm missing something simple but after 3 days I'm getting nowhere... As always, help is much appreciated and tha

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

  
        BVWS.Vardering oWS = new BVWS.Vardering();        BVWS.strucBPVardering oSvar1 = new BVWS.strucBPVardering();        BVWS.StrucPaket oPaket = new BVWS.StrucPaket();                 if (Page.IsPostBack)        {             oSvar1 = oWS.BpVardering("", "", regnummer.Text, "2000", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", DropDownList1.SelectedValue);      tdCHK1.Visible = false;                  try            {                if (oSvar1.rubst01.Length > 0)                {                   

Object reference not set to an instance of an object.

  
When  can debugg the code it will give the error "Object reference not set to an instance of an object.". The code is--     using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using SMC.AlphaAccounting.EntryControls; using SMC.AlphaAccounting.PlugIns; using SMC.PlugInContracts; using SMC.BusinessObjects; using SMC.Utils; using SMC; using SMC.AlphaAccounting; using SMC.AlphaAccounting.DataEntry; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinMaskedEdit; using Infragistics.Win.UltraWinToolbars; namespace WindowsApplication3 {     public partial class FormCountry : SmcDataEntry     {         private boGlChart boLocalGlChart;         private boVendors boLocalVendors;         public FormCountry()         {             InitializeComponent();             this.ultraNumericUniqueID.KeyDown += new KeyEventHandler(ultraNumericUniqueID_KeyDown);             this.ultraNumericUniqueID.KeyPress &
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend