|
|
 |
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.
|
 |

April 26th, 2004, 03:37 PM
|
|
Registered User
|
|
Join Date: Apr 2004
Location: Köping, , Sweden.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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();
|

April 26th, 2004, 04:06 PM
|
 |
Wrox Author
Points: 33,554, Level: 80 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,228
Thanks: 7
Thanked 203 Times in 201 Posts
|
|
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.
|

April 26th, 2004, 06:55 PM
|
|
Registered User
|
|
Join Date: Apr 2004
Location: Köping, , Sweden.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ah tnx man, U did it, U solved the problem. I cant thank u enough :)
domo arigato!!!
|

April 27th, 2004, 02:41 AM
|
 |
Wrox Author
Points: 33,554, Level: 80 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,228
Thanks: 7
Thanked 203 Times in 201 Posts
|
|
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
|

April 27th, 2004, 03:22 AM
|
|
Registered User
|
|
Join Date: Apr 2004
Location: Köping, , Sweden.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 6th, 2004, 10:37 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

May 7th, 2004, 03:03 AM
|
 |
Wrox Author
Points: 33,554, Level: 80 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,228
Thanks: 7
Thanked 203 Times in 201 Posts
|
|
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?
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |