匿名用户无法通过表单身份验证和输出缓存访问 DependencyHandler.axd。
启用表单身份验证
<authentication mode="Forms">
<forms loginUrl="~/account/" slidingExpiration="true" timeout="10080" requireSSL="true" />
</authentication>
配置输出缓存
<caching>
<outputCache enableOutputCache="true" defaultProvider="Memcached">
<providers>
<add name="Memcached" type="Enyim.Caching.Web.MemcachedOutputCacheProvider, Enyim.Caching.Web" />
</providers>
</outputCache>
</caching>
配置 CDF:
<clientDependency loggerType="" version="15">
<fileRegistration>
<providers>
<clear />
</providers>
</fileRegistration>
<compositeFiles defaultFileProcessingProvider="CompositeFileProcessor" defaultFileMapProvider="XmlFileMap" compositeFileHandlerPath="~/DependencyHandler.axd">
<fileProcessingProviders>
<clear />
<add name="CompositeFileProcessor" type="ClientDependency.Core.CompositeFiles.Providers.CompositeFileProcessingProvider, ClientDependency.Core" urlType="Base64QueryStrings" persistFiles="false" />
</fileProcessingProviders>
</compositeFiles>
</clientDependency>
看起来FormsAuthenticationModule跳过了 .axd 文件,因此它没有初始化用户,然后在执行OutputCacheModule时抛出异常,因为用户为 null onLeave 事件。
例外是在第1882行RequestRequiresAuthorization()
异常详情:
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.HttpContext.RequestRequiresAuthorization()
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)