I have a very query intensive user control that I want to cache...i put a cache directive at the top of my user control:<BR><BR><%@ OutputCache Duration="1800" VaryByParam="none" %><BR><BR>The control is loaded programmatically as such:<BR><BR>dim c1 as UserControl<BR>c1 = Page.LoadControl(category)<BR>stats_row.Controls.Add(c1)<BR><BR>When I put the cache directive I get a System.InvalidCastException error and it says to include a debug directive to view the details...which I included and didnt get any more information with. Here is the stack trace:<BR><BR>[InvalidCastException: Exception of type System.InvalidCastException was thrown.]<BR> ASP.stats_advanced_ascx.Page_Load(Object sender, EventArgs e) +95<BR> System.Web.UI.Control.OnLoad(EventArgs e) +67<BR> System.Web.UI.Control.LoadRecursive() +75<BR> System.Web.UI.Control.LoadRecursive() +114<BR> System.Web.UI.Control.LoadRecursive() +114<BR> System.Web.UI.Control.LoadRecursive() +114<BR> System.Web.UI.Page.ProcessRequestMain() +394<BR><BR>I am not experienced using the caching, but as I understand it, it is relatively simple requiring only the directive at the top of the page.<BR><BR>What happens if you place the control on the page in a non-dynamic fashion, like:<BR><BR><%@ Register TagPrefix="a" TagName="b" Src=http://aspmessageboard.com/archive/index.php/"UserControlFile.ascx" %><BR><BR><a:b runat="server" /><BR><BR>Everything works fine then or do you still get the errors? I've not done much with adding user controls dynamically myself.Well I haven't tried that as I need to be able to add it programmatically. If I can't add it programmatically and cache it, its better off not caching. The usercontrol is programmatically added to another usercontrol which is also added programmatically to the shell page. If I can't add it programmatically I'm screwed.