Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 17th, 2008, 10:26 AM
Authorized User
 
Join Date: Aug 2008
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?

 
Old October 17th, 2008, 01:18 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.
 
Old October 17th, 2008, 05:22 PM
Authorized User
 
Join Date: Aug 2008
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)";
        }

 
Old October 18th, 2008, 04:10 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.
 
Old October 19th, 2008, 10:46 AM
Authorized User
 
Join Date: Aug 2008
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. :-)






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.