Dynamics CRM 2015 门户演练中提到的 cache.axd 处理程序是什么(以及在哪里)?

What (and where) is the cache.axd handler referred to in the Dynamics CRM 2015 Portal walkthroughs?

我们正在调查 Microsoft Dynamics CRM 2015 的开发人员扩展包。在 this article 中,他们向您展示了如何添加一个 CRM 插件,该插件将在 CRM 中更新实体时使您网站的缓存数据无效。

文章说:

The URL to your cache invalidation will be http(s)://your-website-domain/Cache.axd.

我的解决方案中没有 Cache.axd,也没有任何配置行可以将此处理程序映射到我的解决方案引用的 Microsoft DLL 中的 DLL 或其他组件。对 http://mysolution/Cache.axd returns 未找到 HTTP 404.0 的 HTTP 请求。

Cache.axd在哪里?它来自哪里,它是如何工作的?我在 Dynamics CRM SDK 或文档中的任何地方都找不到对它的引用。

Cache.axd URL 需要映射到 CRM SDK 附带的 Microsoft.Xrm.Portal.Web.Handlers.CacheInvalidationHandler class。

想法是自定义门户缓存数据以提高性能,然后当 CRM 中发生某些变化时,您可以使用上面文章中描述的方法使门户缓存无效。

... web notification URL (from the Settings menu) that goes to the cache invalidation handler of your website ...

Cache can also be invalidated manually by recycling the application pool, rebuilding the website in Microsoft Visual Studio, saving the web.config file, or by adding a browser toolbar button that will hit the cache invalidation handler. This will refresh the website with the Microsoft Dynamics CRM changes.

我碰巧知道这个,因为这与 AdxStudio 使用的方法相同。本文介绍了 AdxStudio 的参与并提供了下载门户网站的链接(如果您还没有的话)。 Announcing the Customer and Partner Relationship Management Portals!.

如果您正在使用上述加速器构建门户,那么 Cache.axd 将与您相关。如果您只是构建自定义内容,那么缓存的使用和实现由您决定。

找到了。它在 Microsoft.Xrm.Portal.Web.Handlers 中,需要通过您的 web.config 文件进行配置,如下所示:

<system.webServer>
  <handlers>
    <add name="XrmCacheInvalidationHandler" path="cache.axd" verb="*" type="Microsoft.Xrm.Portal.Web.Handlers.CacheInvalidationHandler, Microsoft.Xrm.Portal" resourceType="Unspecified" />
  </handlers>
</system.webServer>

据我所知,根本没有关于此组件或其工作原理的文档。显然有一个支持此组件的 CRM 托管解决方案,它将在 Dynamics CRM Marketplace "soon" 中提供 - 但还没有迹象 - 所以我在 Reflector 中打开了 DLL 以查看它的作用。

要刷新整个缓存,请使用:

GET /Cache.axd?Message=InvalidateAll

要刷新特定实体,请使用

GET /Cache.axd?EntityName=contact&Message=Update&Id={00000000-1111-2222-3333-ABCD12341234}

支持的 Message 值似乎是 PublishUpdateCreateInvalidateAll,我猜它映射到注册自定义 CRM 插件时可用的消息。