Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 17th, 2008, 10:26 AM
Authorized User
 
Join Date: Aug 2008
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 14: Caching problem

I am working on the exercise on page 512. From the Contact Us page I am able to send the original email. However, when I go back to the Contact Us page to send the second email, where caching takes place, I get a page error.

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

Code: 0

Any ideas on this error?

Reply With Quote
  #2 (permalink)  
Old October 17th, 2008, 01:18 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Did you make any changes to the code? If so, can you post it here?

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old October 17th, 2008, 05:22 PM
Authorized User
 
Join Date: Aug 2008
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following code that I added ContactForms.acsx.cs seems to be what is causing the problem:

        if (Cache["ContactFormMailBody"] == null)
        {
            mailBody = System.IO.File.ReadAllText(fileName);
            Cache.Insert("ContactFormMailBody", mailBody, new CacheDependency(fileName));
        }
        else
        {
            mailBody = Cache["ContentFormMailBody"].ToString() + "\r\n(File from the cache)";
        }

Reply With Quote
  #4 (permalink)  
Old October 18th, 2008, 04:10 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Take a look at the Cache keys you are using:
Code:
if (Cache["ContactFormMailBody"] == null)
{
  mailBody = System.IO.File.ReadAllText(fileName);
  Cache.Insert("ContactFormMailBody", mailBody, new CacheDependency(fileName));
}
else
{
  mailBody = Cache["ContentFormMailBody"].ToString() + "\r\n(File from the cache)";
}
You check for one key (ContactFormMailBody) and insert that in the cache, but then in the else block you try to access another key (ContentFormMailBody).

Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #5 (permalink)  
Old October 19th, 2008, 10:46 AM
Authorized User
 
Join Date: Aug 2008
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar. I have been a software developer for 21 years and sometimes it still takes 2 sets of eyes to find a problem. :-)

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem : Sketcher in chapter 14 chang82 BOOK: Ivor Horton's Beginning Visual C++ 2005 1 September 8th, 2008 02:29 AM
Chapter 14 - use of CObject problem jabuck BOOK: Ivor Horton's Beginning Visual C++ 2005 0 February 15th, 2007 02:25 PM
Problem with code on Chapter 14 aargyri BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 June 6th, 2006 03:37 PM
chapter 14 Try It Out problem - update Jams30 BOOK: Beginning ASP 3.0 1 March 22nd, 2004 12:59 PM



All times are GMT -4. The time now is 01:18 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.