p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869

Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2004, 03:37 PM
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Köping, , Sweden.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Object reference not set to an instance...

:D Hi everybody! :D

Ive got a problem (for u hackers out there) with the ThePhile website (the download from
 wrox). Every module works fine the only one giving me a hard time is the forums module,
I can view the forums and the topics and their answers. But if I try to  add a topic,
response or try to register as a forum user the system goes down on me, and the
following error message is displayed. Could enyone help me? Ive seen a few people with
this problem but nobody seems to know the answer.


Code:
An unexpected error has occurred on this page. The system administrators have been 
notified. Please feel free to contact us with the information surrounding this error.

The error occurred in: http://localhost/ThePhile/Modules/Fo...tMessage.aspx?
Action=NewTopic&ForumID=25

Error Message: Object reference not set to an instance of an object.


Stack Trace: 
System.NullReferenceException: Object reference not set to an instance of an object. at
Wrox.WebModules.Forums.Web.PostMessage.Page_Load(Object sender, EventArgs e) in 
c:\inetpub\wwwroot\thephile\modules\forums\postmessage.aspx.cs:line 93 at 
System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad
(EventArgs e) at System.Web.UI.Control.LoadRecursive() at 
System.Web.UI.Page.ProcessRequestMain()
And this is what line 93 says....


Code:
ViewState["ReferrerUrl"] = Request.UrlReferrer.ToString();
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old April 26th, 2004, 04:06 PM
Imar's Avatar
Wrox Author
Points: 33,554, Level: 80
Points: 33,554, Level: 80 Points: 33,554, Level: 80 Points: 33,554, Level: 80
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,228
Thanks: 7
Thanked 203 Times in 201 Posts
Default

Hi there,

Are you by any chance running a firewall like Norton Internet Security? There is a Privacy Protection mechanism that blocks sending the URL Referrer. This is also an issue on this forum if you edit one of your own messages. If the firewall blocks the referrer, it makes sense the code crashes.
Another cause is that the page is requested directly. In that case, there is no referrer, as a referrer is only available when you open a page by clicking a link for example on another page.

I think in both case, you can use some defensive coding mechanism to protect your from this error:
Code:
if (Request.UrlReferrer != null)
{
  // Referrer found. Save to ViewState
  ViewState["ReferrerUrl"] = Request.UrlReferrer.ToString();
}
else
{
  // Referrer not found. Reset ViewState, or save / change 
  // anything you see fit.
  ViewState["ReferrerUrl"] = "";
}
Does this help?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old April 26th, 2004, 06:55 PM
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Köping, , Sweden.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ah tnx man, U did it, U solved the problem. I cant thank u enough :)

domo arigato!!!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old April 27th, 2004, 02:41 AM
Imar's Avatar
Wrox Author
Points: 33,554, Level: 80
Points: 33,554, Level: 80 Points: 33,554, Level: 80 Points: 33,554, Level: 80
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,228
Thanks: 7
Thanked 203 Times in 201 Posts
Default

Out of curiosity (and future reference), how did you finally solve the problem?

Was it a firewall that caused the referrer to be empty?

Imar


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old April 27th, 2004, 03:22 AM
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Köping, , Sweden.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well kind of, It was the Privacy Control in Norton Internet Security, not the firewall itself. This should fix it for you guys out there with the same problem.

Code:
http://www.theboyz.nu/images/norton.jpg
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old May 6th, 2004, 10:37 PM
Authorized User
Points: 95, Level: 1
Points: 95, Level: 1 Points: 95, Level: 1 Points: 95, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Imar and steelman for the great posts. I was having the same problem too. I was perplexed because at one point I had the forums working fine. Now I know it was when I had Norton Internet Security 2002 installed. So, my guess is that this problem first started occuring after I installed Internet Security 2003. Turning off Privacy Control fixed the problem for me...

Thanks,
d.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old May 7th, 2004, 03:03 AM
Imar's Avatar
Wrox Author
Points: 33,554, Level: 80
Points: 33,554, Level: 80 Points: 33,554, Level: 80 Points: 33,554, Level: 80
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,228
Thanks: 7
Thanked 203 Times in 201 Posts
Default

Just remember that turning off Privacy Control fixes the problem for you as a user, but not for the application. So, anyone else with this kind of Privacy control software will run into the same issue when they visit your forum.

It's best to modify your code so it catches those situations by checking if Request.UrlReferrer is null or not, as I demonstrated in my earlier post.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Suck it Up by Hed Planet Earth (Track 1 from the album: Blackout ) What's This?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Object reference not set to an instance of an obje rturner003 ASP.NET 2.0 Professional 0 December 26th, 2006 08:30 PM
Object reference not set to an instance of an obj nrathod_97 BOOK: Beginning VB.NET Databases 4 June 21st, 2005 07:35 PM
Object Reference is Not Set to an Instance of an O blackinwhite General .NET 4 February 1st, 2005 05:42 AM
Object reference not set to an instance of an obje williadn General .NET 0 January 18th, 2005 05:39 PM
Object reference not set to an instance of an obje aashishpatil ASP.NET 1.1 1 October 8th, 2003 10:17 AM



All times are GMT -4. The time now is 02:03 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc