473,394 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Partial caching (a UserControl) with file dependency

Hello,
I want to partial cache by using a UserControl.

Now I have a file dependency.

In msdn I see it is not possible to do it the same way as in a page.

The only information is to create a file dependency and assign it to
Dependency property.

But UserControl has no Dependency Property.

What can I do.

Thank you for any help.

Rolf Welskes
Oct 17 '06 #1
6 2741
Hello Rolf,

As for the ASP.NET Output Cache, the UserControl(partial cache on page)
only provide limited cache dependency/policy support. You can find them
when typing the @OutputCache diretive in ascx template. e.g.

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="HelloWorldUC.ascx.cs" Inherits="usercontrols_HelloWorldUC" %>
<%@ OutputCache Duration="30" VaryByParam="none" %>

In ASP.NET 2.0, usercontrol can be configured to cache upon the following
dependency:

** Timespan

**SqlDependency

**VaryByParam (querystring, control, form variables...)

**VaryByCustom(browser or custom setting...)

I've also check the FileDependency and the Dependency property you
mentioned, actually, there is programmatic interface for adding
filedependency for ASP.NET page's outputCache, it is done through
HttpResponse.AddXXXDependency methods. Unfortunately, so far the
UserControl hasn't provide this functionality, this is also limited due to
the ASP.NET output cache's granularity(output cache is based on a complete
page response).

BTW, would you tell me some detailed info or code logic about the page and
usercontrol that will want to use FileDependency cache? We can try to do
some further research to see whether we can find any other approach to
achive the same goal.

Please feel free to let me know if you have any other questions or concern
on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 18 '06 #2
Hello,
thank you for your informations.

What I want is very simple.

I have a page which is not cached.
In this page I have a usercontrol which is cached.
Total this means we have partial caching.

But, if the file data.txt is changed the cache of the usercontrol must get
invalid
because new calculation is neccessary.

I cannot cache the page because many calculations for each request are
neccessary.

One way could be because the page is not cached, to check the file in the
page code and
make the cache for the usercontrol invalid when the file has changed, but
how to make the cache of a user control invalid?

Thank you for any help.
Rolf Welskes


"Steven Cheng[MSFT]" <st*****@online.microsoft.comschrieb im Newsbeitrag
news:Zs**************@TK2MSFTNGXA01.phx.gbl...
Hello Rolf,

As for the ASP.NET Output Cache, the UserControl(partial cache on page)
only provide limited cache dependency/policy support. You can find them
when typing the @OutputCache diretive in ascx template. e.g.

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="HelloWorldUC.ascx.cs" Inherits="usercontrols_HelloWorldUC" %>
<%@ OutputCache Duration="30" VaryByParam="none" %>

In ASP.NET 2.0, usercontrol can be configured to cache upon the following
dependency:

** Timespan

**SqlDependency

**VaryByParam (querystring, control, form variables...)

**VaryByCustom(browser or custom setting...)

I've also check the FileDependency and the Dependency property you
mentioned, actually, there is programmatic interface for adding
filedependency for ASP.NET page's outputCache, it is done through
HttpResponse.AddXXXDependency methods. Unfortunately, so far the
UserControl hasn't provide this functionality, this is also limited due to
the ASP.NET output cache's granularity(output cache is based on a complete
page response).

BTW, would you tell me some detailed info or code logic about the page and
usercontrol that will want to use FileDependency cache? We can try to do
some further research to see whether we can find any other approach to
achive the same goal.

Please feel free to let me know if you have any other questions or concern
on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Oct 18 '06 #3
Hello Rolf,

Thanks for your reply and the further description.

For your scenario, you want the usercontrol's cache depend on a certain
external disk file. Since Usercontrol doesn't directly support
FileDependency in its cache dependency options, we need to look for other
means.

Based on my research, here is one possible solution to make UserControl
cached based on a certain file.

** You can set Usercontrol to use "VaryByCustom" cache and use
customstring as cache option. See the below msdn reference:

#How to: Cache Versions of a Page Using Custom Strings
http://msdn2.microsoft.com/en-us/library/5ecf4420.aspx
And in the overrided "GetVaryByCustomString" method, we use System.IO.File
class to query the certain file's "LastModified Date" attribute and return
this as the value of our customstring. e.g.

=========in global.asax===============
public override string GetVaryByCustomString(
HttpContext context,
string custom
)
{
if (custom == "filestring")
{
return
System.IO.File.GetLastWriteTimeUtc(@"D:\temp\file_ temp\test.log").Ticks.ToSt
ring();
}

return null;

}
===================================

the "filestring" correspond to the customstring in the below cache
directive of our usercontrol:
=====================
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="HelloWorldUC.ascx.cs" Inherits="usercontrols_HelloWorldUC" %>
<%@ OutputCache Duration="100" VaryByParam="None" VaryByCustom="filestring"
%>

==================

Please feel free to let me know if you have anything unclear.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Oct 19 '06 #4
Hello,
thank you,
I have tested it.
It works,
BUT !!!!!!
if I have for example the cache time for the custom control on 6 hours.
And if the file is changed all 10 mintues,
we have after 6 hours 36 times the cached control in the cache,
because what we have is no dependency but a varybycustom,
means, the old cached value is not removed.

It's possible to do it, but is no good solution.

So, hope it will be solved in a service pack or next version.

Remark:
I have seen many cases where the basic functionality for a page is not
avaiblable for web custom control.
And this is bad, because many pages are build from web custom controls.
I have given a hint to microsoft in these other cases.

Thank you again.
Rolf Welskes
Oct 19 '06 #5
Thanks for your followup Rolf,

I agree with you, the customstring solution will cause many cached copy and
will add performance overhead when the usercontrol's content is large.

BTW, is your usercontrol only display one read-only data and will it need
to interact with other part of the page. If not, another approach is moved
the usercontrol's content into a separate page and embed this page in the
original page through html <iframeelement. Thus, you can use the
FileDependeny cache for that indiviual separate page.

Anyway, I also think it is a good idea that the usercontrol support more
featuers(not only about cache options) like the page supports. Actually,
the usercontrol has been enhanced much from 1.1 (e.g ascx usercontrol has
support design-time rendering in page designer, and can support inner html
template). Therefore, I would suggest you send this suggestion to the .net
feedback site so that the product team can hear on this.
#Visual Studio and .NET Framework Feedback
http://connect.microsoft.com/feedbac...spx?SiteID=210

Thanks again for your posting and the sincere feedback.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 20 '06 #6
Hello,
thank you for your work.
I hope we will have it in a future version.
Thank you again.
Rolf Welskes

"Steven Cheng[MSFT]" <st*****@online.microsoft.comschrieb im Newsbeitrag
news:cC**************@TK2MSFTNGXA01.phx.gbl...
Thanks for your followup Rolf,

I agree with you, the customstring solution will cause many cached copy
and
will add performance overhead when the usercontrol's content is large.

BTW, is your usercontrol only display one read-only data and will it need
to interact with other part of the page. If not, another approach is moved
the usercontrol's content into a separate page and embed this page in the
original page through html <iframeelement. Thus, you can use the
FileDependeny cache for that indiviual separate page.

Anyway, I also think it is a good idea that the usercontrol support more
featuers(not only about cache options) like the page supports. Actually,
the usercontrol has been enhanced much from 1.1 (e.g ascx usercontrol has
support design-time rendering in page designer, and can support inner html
template). Therefore, I would suggest you send this suggestion to the .net
feedback site so that the product team can hear on this.
#Visual Studio and .NET Framework Feedback
http://connect.microsoft.com/feedbac...spx?SiteID=210

Thanks again for your posting and the sincere feedback.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.

Oct 24 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dr Evil | last post by:
Greetings. Has anyone ever seen a tool that will read directories of header file source code and generate a dependency tree? I've often encountered large projects where such a tool would be useful....
11
by: Michael Gaab | last post by:
Compilation in c generally has four phases 1. Preprocessing 2. Compilation 3. Assembly 4. Linking. If I use a flag that will not link the code, order of compilation is not an issue,...
0
by: Manish Jain | last post by:
I am trying to implement Partical Caching in a User Control that gets data from DB and populates a combo based on: 1) GroupKey : An int Property that is known for each call (say Source=10, Code=11...
0
by: Ryan Gregg | last post by:
I'm working with a user control that hits a web service and builds a result from that. I'd like to use partial caching to cache the object to prevent a heavy load on the web service (since the...
3
by: TJO | last post by:
My asp.net 1.1 app is loading an xml file into cache so that subsequent calls for the xml file will not be pulled from the file system but from the cache instead. My method for loading the xml...
0
by: baldwin | last post by:
Hi, I am trying different caching features of asp.net. I came to a point that I want to cache the content in a master file. Is it possible to cache the contents in Master File? User controls can...
1
by: the4man | last post by:
Hi all!! I have a very stupid and simple project, just for testing, with only one page (default.aspx), and one user control. The user control only shows the time in an asp:literal each time the...
1
by: IanO | last post by:
Getting data from an database and displaying it on a web page is some thing I have done for years. Now instead of getting data from a database, I want to get the text of a file and display that on...
7
by: Andrew Jocelyn | last post by:
Hi I'm running an ASP.NET web application under IIS. I'm inserting a cache object with a file based CacheDependency. I've noticed that when the file changes the Cache object is not always...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.