473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Null Reference Exception when run under machine name

I am having a very stange issue happen to my web application. I am
trying to develop a simple shopping cart. The code works perfectly
when I run the application under http://localhost/myapp. However, when
I try to run the same app under the machine name http://mymachine/myapp
I recieve a Null Reference Exception and the page crashes. I can't
figure out why this is happening. The Null Reference is referring to a
Session variable containing a dynamic DataTable which has the items the
user has chosen to purchase. The Store and the Shopping Cart are all
in 1 web form (only trying to sell t-shirts). Can anyone give me a
hint as to what may be happening. I am attaching the necessary code
snippets. Thanks in advance.

Dim objDT as DataTable = New DataTable
Dim objDR as DataRow
Private Sub Page_Load(ByVal sender as System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not Page.IsPostBack Then
makeCart()
End If

Function makeCart()
objDT = New System.Data.DataTable("Cart")
'create the columns to store the items in the shopping cart
Session("Cart") = objDT
End Function

Public Sub AddToCart(ByVal s As Object, ByVal e As EventArgs) 'this
handles the click event to add items to the cart.
objDT = Session("Cart")
For Each objDR In objDT.Rows 'this is the line which throws the
Null Reference error. After debugging I found that the Session("Cart")
= Nothing. As I mentioned above, this problem does not occur when run
under 'localhost'.
'do some stuff here
Next
End Sub

Nov 22 '05 #1
0 679

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Shannon | last post by:
I am having a very stange issue happen to my web application. I am trying to develop a simple shopping cart. The code works perfectly when I run the application under http://localhost/myapp. ...
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
7
by: odonel | last post by:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: here is my code: HttpCookie cookie = Request.Cookies;
4
by: rrober07 | last post by:
Hello, My Setup is I have a Web Server machine(Devweb01), Database SQL Machine(Devsql01), a Client Machine(local machine) I have configured the SQL machine as follows: 1) Added local Aspnet...
5
by: Tony Cheng | last post by:
for (int i=0; i<_request.Form.Count; i++ ) { string key = _request.Form.GetKey(i); if ( !key.Equals("formCode") && !key.Equals("formLanguage") && !key.Equals("__VIEWSTATE") &&...
16
by: Paul S. Natanson | last post by:
What is a Null Reference error and how do I fix it? My newly installed VB.Net2003 gives me a "Microsoft Development Environment" error message box EVERY time I try to run/start ANY project -...
1
by: connor7777 | last post by:
Hi guys: We've been weeding out errors off of a java->c# project and have managed to redeem most of our code with the exception of one bug that we for some reason cannot pin down. The following...
11
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When...
1
by: vaibhavchavan | last post by:
Hi I am doing application for signing of soap message with digital certificate . I am using WSE 2.0 I worte the the simple webservice & deployed it on in our server machine . To make it...
2
by: Febria | last post by:
Dear, all... I have some problem with my application. I used UltraWebGrid component in my web application. Unfortunately, when I tried to run the web, the error page displayed: The located...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.