Part 5: ASP.NET Applications on the CRM Offline Client

By philiprichardson

Refer: Part 1, Part 2, Part 2b, Part 3, Part 4

CRM 4.0 allows you write an ASP.NET application and place it on the Offline Client's web server. This application can call our offline web service platform to perform operations against CRM. These files are deployed in the [Program Files]\Microsoft Dynamics CRM\Client\res\web\ISV\[Company Name]\[Application Name]. Typically you'll use an MSI to distribute these files to your clients.

When executing your code offline there are few things you need to know:

  • The Org Name. You get this from the Registry.
  • The Port Number used by the local web server. Typically this is 2525 – however you should always check the registry in case there is a abnormal installation.
  • The Service URLs. You'll construct these by concatenating http://localhost + Port Number + the service path.

You always use Integrated Windows Authentication to access the offline web services. Regardless of the authentication type on the server (including CRM Live). You also aren't required to wrap your code with a CrmImpersonator block (however if you do so – there is no harm). If you write symmetrical code for online/offline – ensure that you don't create the token using ExtractCrmAuthenticationToken method as this is not available offline. You may want to check to see if the code is executing offline (one way to do this is to look at the Request.Url.Host and see if it is 127.0.0.1).

The follow sample shows how this can easily be achieved.

In the next part of this series I'll show you how you can easily create a simple MSI for deploying your code.