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!

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s