将 OutputCache 添加到 ASP.NET WebForm 会使我的网站崩溃:(

发布于 2024-08-26 18:18:04 字数 3013 浏览 3 评论 0原文

当我添加其中之一时...

<%@ OutputCache Duration="600" Location="Any" VaryByParam="*" %>

或者

<%@ OutputCache CacheProfile="CmsArticlesListOrItem" %>

(.. and this into the web.config file...)
<caching>
    <outputCacheSettings>
        <outputCacheProfiles>
            <add name="CmsArticlesListOrItem" duration="600" varyByParam="*" />
         </outputCacheProfiles>
    </outputCacheSettings>

    <sqlCacheDependency ........ ></sqlCacheDependency
</caching>

我的页面/网站崩溃并出现以下错误:-

Source: System.Web
----------------------------------------------------------------------------
TargetSite: System.Web.DirectoryMonitor FindDirectoryMonitor(System.String, Boolean, Boolean)
----------------------------------------------------------------------------
Message:System.Web.HttpException: Directory 'C:\Web Sites\My Site Foo - Main Site\Controls\InfoAdvice' does not exist. Failed to start monitoring file changes.
   at System.Web.FileChangesMonitor.FindDirectoryMonitor(String dir, Boolean addIfNotFound, Boolean throwOnError)
   at System.Web.FileChangesMonitor.StartMonitoringPath(String alias, FileChangeEventHandler callback, FileAttributesData& fad)
   at System.Web.Caching.CacheDependency.Init(Boolean isPublic, String[] filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime utcStart)
   at System.Web.Caching.CacheDependency..ctor(Int32 dummy, String[] filenames, DateTime utcStart)
   at System.Web.Hosting.MapPathBasedVirtualPathProvider.GetCacheDependency(String virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
   at System.Web.ResponseDependencyList.CreateCacheDependency(CacheDependencyType dependencyType, CacheDependency dependency)
   at System.Web.HttpResponse.CreateCacheDependencyForResponse(CacheDependency dependencyVary)
   at System.Web.Caching.OutputCacheModule.InsertResponse(HttpResponse response, HttpContext context, String keyRawResponse, HttpCachePolicySettings settings, CachedVary cachedVary, CachedRawResponse memoryRawResponse)
   at System.Web.Caching.OutputCacheModule.OnLeave(Object source, EventArgs eventArgs)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

好的..所以出于某种原因,OutputCache想要一个文件夹/文件在那里? ? ? ?

嗯,这个网站已经运行了大约 3 年,我很确定文件夹 \Controls\Controls\InfoAdvice 在我的作品中不存在服务器。在我的本地主机上,它确实..并且包含大量的 ascx 控件。

但它们不存在于我的实时服务器上。

那么……这是怎么回事?

有人可以帮忙吗?

哦:)在有人建议我创建这两个文件夹,甚至在这些文件夹中粘贴一个随机文件..并在这些随机文件中包含一些随机文本..我已经这样做了,但它似乎不起作用:(

请帮助!

更新

当我尝试使用 IIS 进行失败的请求跟踪时,我注意到了这一点....

替代文本 http://img136.imageshack.us/img136/1351/notsure.png

When I add either one of these ...

<%@ OutputCache Duration="600" Location="Any" VaryByParam="*" %>

or

<%@ OutputCache CacheProfile="CmsArticlesListOrItem" %>

(.. and this into the web.config file...)
<caching>
    <outputCacheSettings>
        <outputCacheProfiles>
            <add name="CmsArticlesListOrItem" duration="600" varyByParam="*" />
         </outputCacheProfiles>
    </outputCacheSettings>

    <sqlCacheDependency ........ ></sqlCacheDependency
</caching>

my page/site crashes with the following error:-

Source: System.Web
----------------------------------------------------------------------------
TargetSite: System.Web.DirectoryMonitor FindDirectoryMonitor(System.String, Boolean, Boolean)
----------------------------------------------------------------------------
Message:System.Web.HttpException: Directory 'C:\Web Sites\My Site Foo - Main Site\Controls\InfoAdvice' does not exist. Failed to start monitoring file changes.
   at System.Web.FileChangesMonitor.FindDirectoryMonitor(String dir, Boolean addIfNotFound, Boolean throwOnError)
   at System.Web.FileChangesMonitor.StartMonitoringPath(String alias, FileChangeEventHandler callback, FileAttributesData& fad)
   at System.Web.Caching.CacheDependency.Init(Boolean isPublic, String[] filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime utcStart)
   at System.Web.Caching.CacheDependency..ctor(Int32 dummy, String[] filenames, DateTime utcStart)
   at System.Web.Hosting.MapPathBasedVirtualPathProvider.GetCacheDependency(String virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
   at System.Web.ResponseDependencyList.CreateCacheDependency(CacheDependencyType dependencyType, CacheDependency dependency)
   at System.Web.HttpResponse.CreateCacheDependencyForResponse(CacheDependency dependencyVary)
   at System.Web.Caching.OutputCacheModule.InsertResponse(HttpResponse response, HttpContext context, String keyRawResponse, HttpCachePolicySettings settings, CachedVary cachedVary, CachedRawResponse memoryRawResponse)
   at System.Web.Caching.OutputCacheModule.OnLeave(Object source, EventArgs eventArgs)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Ok .. so for some reason, the OutputCache wants a folder/file to be there? ? ? ?

Well, i've had this site live for around 3 years and i'm pretty sure that the folders \Controls and \Controls\InfoAdvice doesn't exist on my production server. On my localhost, it sure does .. and contains a large list of ascx controls.

But they don't exist on my live server.

So ... what is going on here?

Can anyone please help?

Oh :) Before someone suggests I create those two folders and even stick a random file in those folders .. and have some random text in those random files .. i've done that and it doesn't seem to work, still :(

Please Help !

Update

When i tried to do a FAILED REQUEST TRACE with IIS, I noticed this....

alt text http://img136.imageshack.us/img136/1351/notsure.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ㄟ。诗瑗 2024-09-02 18:18:04

唔。我不确定这是否是一个可以接受的答案,但我已经弄清楚了。

  1. 该项目是一个 ASP.NET 网站(与 Web 应用程序MVC1/2 类型相反)。
  2. 我必须为该控件创建一个文件夹,该文件夹位于 aspx 页面上。 (例如 \controls\infoadvice
  3. 我必须为母版页创建一个文件夹,该文件夹由页面 \masterpages 使用,

然后我将一个简单的 txt 文件添加到这两个新文件夹中..其中包含一些虚拟内容。这启用了这些项目“构建”以进行部署时要发布的文件夹(和虚拟文件)(我正在使用 Web 部署项目 + TFS 构建),

所以问题是缓存需要检查文件夹 我猜测帐户(网络系统)只是不允许它创建文件夹,如果它不存在..即使我手动授予了根文件夹的权限(我假设,孩子们)

哦,问题解决了。 ..我不喜欢它..但它已经解决了。

Hmm. I'm not sure if this is an acceptable answer or not, but I've sorta figure this out.

  1. The project is an ASP.NET Web Site (as opposed to a Web Aplication or an MVC1/2 type).
  2. I had to create a folder for the control, which exists on the aspx page. (eg. \controls\infoadvice
  3. I had to create a folder for the master page, which is used by the page \masterpages

I then added a simple txt file into both those new folders .. with some dummy content in them. This enabled those folders (and dummy files) to be published when the project is 'built' for deployment (i'm using Web Deployment Projects + TFS Build).

Now it works.

So the problem was that the Caching requires a check for the folder. I'm guessing that the account (NetworkSystem) just doesn't allow it to create the folder if it doesn't exist .. even though i manually gave permissions to the root folder (and i assume, children).

Oh well - problem solved. I don't like it .. but it's solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文