Is the SqlDependency Attribute in OutputCache Directives Required Like VaryByParam Attribute?

This question came up during a presentation on ASP.NET v2.0, “Is the SqlDependency Attribute in OutputCache Directives Required Like VaryByParam Attribute?“

After doing some searching through the MSDN Library for Visual Studio 2005 (Beta 1), I discovered very little documentation about using the OutputCache directive.  So, what is a boy to do?  Go to code!

I added the <% OutputCache %>to a page and watched what happened when I tried to preview it in a browser.  As expected, the parser stated that I had to have the Duration attribute. 

So I then tried <% OutputCache Duration=”1” %>. Of course the parser had trouble with this as well--  Parser Error Message: The directive is missing a 'VaryByParam' attribute. 

As we walk down the path <% OutputCache Duration=”1” VaryByParam=“None“ %>. The page made it pass the Parser and rendered.

Conclusion---SqlDependency is not a required attribute.

Published Thu, Apr 14 2005 3:19 by Keith Nicholson
Filed under:

Comments

# re: Is the SqlDependency Attribute in OutputCache Directives Required Like VaryByParam Attribute?

Friday, April 22, 2005 9:20 AM by Keith Nicholson
Hi
You should use user controls to indicate how their output is cached

# re: Is the SqlDependency Attribute in OutputCache Directives Required Like VaryByParam Attribute?

Friday, May 12, 2006 12:12 AM by Ryan Heath
How about this scenario?

http://discuss.develop.com/archives/wa.exe?A2=ind0605b&L=dotnet-web&T=0&F=&S=&P=1173

We have to put SqlDependency="CommandNotification" otherwise runtime it will break. But on the other side, we have the feeling its still not right, since we see, from time to time, some exceptions popping up, which were not popping up before ...

// Ryan

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Powered by Community Server (Commercial Edition), by Telligent Systems