An Adxstudio Portal application caches results from CRM to improve performance. In order for the portal to get fresh data from CRM, we have to configure the cache invalidation in CRM to notify the portal of CRM data changes. This is done by adding a Web Notification URL in CRM. A Web Notification Plugin registered with the Adxstudio Portals solution in CRM is triggered on all entity create, update, delete, disassociate, associate, publish, and publishall messages and notifies the Web Notification URLs defined in the CRM to invalidate the cache so the users visiting the portal get the recent data changes.

There is no set scheduled time interval for notifying the portal to invalidate its cache. For each event that is processed in the CRM event execution pipeline, such as a create, update, or delete, a new system job for the appropriately registered Web Notification plugin step is created and run that sends an HTTP POST web request to each Web Notification URL to inform the portal cache should be refreshed. These requests usually complete within seconds of the event execution and the portal cache is virtually maintained in realtime, merely seconds behind the actual data change in CRM. Any data operations performed directly by the Portal immediately invalidate its cache without the need for web notifications.

Managing Web Notification URLs in CRM

The Web Notification URLs can be created, edited and deleted within Microsoft Dynamics CRM

  • Login to CRM
  • Navigate to Settings
  • Click Web Notification URLs

To create a new web notification URL

  • Click New

To edit and existing web notification URL

  • Double-click on the existing Web Notification URL listed in the grid

Web Notification URLs

  • Specify a Name of the Portal
  • Specify the URL to your portal and add /Cache.axd to the end of the URL
  • Click Save & Close

Web Notification URL

Attributes & Relationships

The table below explains the Web Notification URL attributes used by Adxstudio Portals.

Name Description
Name  The descriptive name of the record. This field has no impact on Web Notifications and is purely for reference within CRM.
URL 

The URL to your portal's cache invalidation handler.

Example: http://website.com/cache.axd

Example: http://website.com/searchindex.axd

The Web Notification plugin runs in a sandbox, which has an additional restriction on what URLs can be used. IP addresses and localhost URLs are NOT allowed as outbound HTTP calls from the CRM sandbox service. Therefore the URL must consist of a domain name. Therefore URLs such as http://10.100.1.2/Cache.axd or http://localhost/Cache.axd are not valid.

Web Notification Plugin

The plugin included in the installation must be activated in order for the cache invalidation to be triggered by a web notification.

  • Login to CRM
  • Navigate to Settings
  • Click Solutions
  • Open Adxstudio Portals Base

Customize the System

  • The solution should open on the Configuration page
  • Click Enable Notifications in the left bottom corner

Once notifications have been enabled, you can adjust which entities will have notifications sent, and which entities will be ignored (no notifications sent for changes). Click Save and Publish to save your changes.

If web notifications have been enabled and a change is made to the Web Notification URLs, the web notifications need to be disabled and then enabled again in order to have the changes to the URLs properly registered.

Portal Configuration

The following handler declaration should exist in the portal's web.config file in order for the website to process the HTTP POST request made by the web notifications. This will already exist in the web.config we distribute in the MasterPortal project. If your web.config does not include this handler declaration, you will need to add it.

<configuration>
  <system.webServer>
    <handlers>
      <add name="CacheInvalidation" verb="*" path="Cache.axd" preCondition="integratedMode" type="Adxstudio.Xrm.Web.Handlers.CacheInvalidationHandler, Adxstudio.Xrm"/>
    </handlers>
  </system.webServer>
</configuration>

Validate Web Notifications

To verify that the web notifications have been configured correctly and that the portal's cache is being refreshed when changes are made to entities within CRM, complete the following steps.

If tracing is enabled in the website, you can verify that web notifications are configured correctly by viewing the portal's trace.axd handler. See ASP.Net Tracing.

  • Login to CRM
  • Open any entity record
  • Make a change to a field.
  • Click Save & Close
  • Wait momentarily for the asynchronous plugin may take a minute to process.
  • Open a web browser and navigate to the website's URL and append /trace.axd to view the trace
  • If there is a POST to the cache.axd then web notifications are working.

Trace

  • If there are no POSTs to the cache.axd then web notification are not working.
    • Login to CRM
    • Navigate to Settings
    • Click System Jobs
    • Review the jobs listed and determine if the various Adxstudio.Xrm.Plugins.WebNotificationPlugin jobs have Succeeded or Failed.
    • If there are no WebNotificationPlugin jobs listed
      • This may indicate that the plugins are not enabled. See Web Notification Plugin above.
    • If the jobs are marked Succeeded
      • This may indicate that the portal is not responding to the notifications or the CRM server is unable to communicate with the portal's web server.
    • If there are jobs that have failed
      • Double-click on the job and view the error details. The details should indicate the reason for the failed job and should help troubleshoot the problem.

Otherwise, if tracing is not enabled

  • Login to CRM
  • Navigate to Portals
  • Click Web Pages
  • Double-click on the Home web page listed in the grid
  • Modify the Copy field by adding some arbitrary text.
  • Click Save & Close
  • Open the website's URL to the home page in your web browser
  • Verify that the arbitrary text added in a previous step is showing up on the page. 
  • If the text is appearing on the page, this indicates the cache is being refreshed and you are done. Don't forget to edit the page and remove the arbitrary text. 
  • If the page does not display the newly added text then something is not configured correctly.
    • This may indicate that the plugins are not enabled. See Web Notification Plugin above.
    • This may indicate that the portal is not responding to the notifications or the CRM server is unable to communicate with the portal's web server.
    • Double-click on the job and view the error details. The details should indicate the reason for the failed job and should help troubleshoot the problem.
    • Login to CRM
    • Navigate to Settings
    • Click System Jobs
    • Review the jobs listed and determine if the various Adxstudio.Xrm.Plugins.WebNotificationPlugin jobs have Succeeded or Failed.
    • If there are no WebNotificationPlugin jobs listed
    • If the jobs are marked Succeeded
    • If there are jobs that have failed

Batch Data Operations

If large-scale data operations such as a bulk data import occur, the volume of system jobs running WebNotificationPlugin steps may impact the execution of other system jobs or negatively affect the performance of the portal. If your environment is experiencing this, it may be best to disable the plugin steps for the WebNotificationPlugin temporarily and then enable them once these large-scale data operations have completed. While the plugin steps are disabled, the portal cache will become stale and you will need to invalidate the cache once your large-scale data operations are complete and you have re-enabled the plugin steps. You can force the portal cache to be invalidated/refreshed either by making a web request to the portal's cache handler URL including ?Message=InvalidateAll, or by recycling the IIS website's application pool.