Get The Server URL in Silverlight using HTML Web Resource in ms crm 2011 + silverlight

Get The Server URL in Silverlight using HTML Web Resource in ms crm 2011 + silverlight

private void GetServerUrl()

        {

            if (Application.Current.Host.Source.Port == 80)

                serverUrl = string.Format(http://{0}/”, Application.Current.Host.Source.DnsSafeHost);

            else

                serverUrl = string.Format(http://{0}:{1}/”, Application.Current.Host.Source.DnsSafeHost, Application.Current.Host.Source.Port);

            string OrgName = HtmlPage.Document.QueryString[“orgname”];

            if (!serverUrl.Contains(“dynamics.com”))

                serverUrl = serverUrl + OrgName;

            if (serverUrl.EndsWith(“/”))

                serverUrl = serverUrl.Substring(0, serverUrl.Length – 1);

            serverUrl = serverUrl + “/xrmservices/2011/organizationdata.svc/”;
            context = new ViveksContext(new Uri(serverUrl, UriKind.Absolute));

        }

Cheers,

Advertisements

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