ASP.NET double page load

I had a problem on a piece of work today that was caused by ASP.NET loading a web page twice. The problem was caused by me caching some information read from a database. The initial page load had the old URL, including the QueryString, so my caching code was loading the last record rather than the current record. Luckily, I had property within my aspx page that looked at the QueryString. So, I could use that to check that the cached record was the correct one, and if not I could then refresh my cache.

There seem to many different reasons for a double page load, including having AutoEventWireup set to true, and “#” as the src for an image. But, my particular case wasn’t cured by the solutions for those. So, I ended up with the above work-around.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s