B
Bob
I have several simple user controls (e.g. header, footer) that have static
content so I thought it would be a good idea to turn on the ouput cache. So
I added <%@ OutputCache Duration="600" Shared="True" VaryByParam="none" %>
to the control. I have a base page class that overrides the Render() method
to load these controls:
protected override void Render(HtmlTextWriter writer) {
.........
LoadControl(Config.AppRoot +
"Ctrl/Header.ascx").RenderControl(writer);
.........
The above line throws System.NullReferenceException: Object reference not
set to an instance of an object. However, if I remove the OutputCache
directive, it works fine. Also if I put the user control in the page load
event handler rather than in the overriden Render method, it works fine too.
Does anyone know what the problem is? And how can I keep these common user
controls in the base page class, and at the same time take advantage of the
output cache feature?
Thanks
Bob
content so I thought it would be a good idea to turn on the ouput cache. So
I added <%@ OutputCache Duration="600" Shared="True" VaryByParam="none" %>
to the control. I have a base page class that overrides the Render() method
to load these controls:
protected override void Render(HtmlTextWriter writer) {
.........
LoadControl(Config.AppRoot +
"Ctrl/Header.ascx").RenderControl(writer);
.........
The above line throws System.NullReferenceException: Object reference not
set to an instance of an object. However, if I remove the OutputCache
directive, it works fine. Also if I put the user control in the page load
event handler rather than in the overriden Render method, it works fine too.
Does anyone know what the problem is? And how can I keep these common user
controls in the base page class, and at the same time take advantage of the
output cache feature?
Thanks
Bob