Wednesday, December 26, 2012

Disable Caching in ASP.NET

Some time ago i had a issue such that i had some records in a GridView and an option to update each record. I updated a record, but still the GridView showed the old record. I checked the database and it's updated as expected.

Issue was caching on the web page. So that even though the record is updated web page still showed the old record.

To remove caching in ASP.NET you can use below code in page load event.

Response.Expires =-1500;
Response.CacheControl = "no-cache";

No comments:
Write comments
Recommended Posts × +