Using getClientUrl() in CRM 2013 and how is is different from getServerUrl() – Microsoft Dynamics CRM

Recently in my training sessions, i am coming up with this question very frequently. Hence thought of sharing. I am pretty sure that many of you might already know this by now. However this post might be of help to somebody trying their first hands on CRM 2013 and having this question in mind.

First let’s shift our focus to getServerUrl(). Well first of all even if you are in  CRM 2011 and you have upgraded to Update Rollup 12 and still using this method, please do not use the same as it has been deprecated.

Now when we used getServerUrl(), it used to return the Url that is registered in the CRM deployment Manager. However there are some situations where the user might be accessing the application using a URL different from the base server url such as an IP address or a domain alias. In these situations it will be cross domain calls and hence it would fail.

getClientUrl() as the method name itself suggests, does not blindly return the base server url. Instead it looks at the url that was used to access the CRM application. Hence no cross domain issue.

Isn’t it great to get rid of the access denied error messages that we used to get during rest calls while using getServerlUrl() !

 

Hope this helps!

Advertisements

About Debajit
I am a Dynamics CRM Most Valuable Professional (MVP) with 10 years of experience in Microsoft .NET Technologies and 7 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: