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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.