locked
Silverlight get crm server name RRS feed

  • Question

  • I have a silverlight app and I used the server url in the code. I want to make it dynamic. How can I get the server url, in a silverlight app that is not a web resource. I want to use it from the sidebar.

    Thanks for your help!

    Monday, August 8, 2011 12:15 PM

Answers

  • Hi,

    If the Xrm.page.context is unavailable to your application then in silverlight try us the code below:

     

    jj_ServerUrl = HtmlPage.Document.DocumentUri.ToString();

     You may also try:

    Application.Current.Host.Source.Host;


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    • Proposed as answer by Jehanzeb.Javeed Monday, August 8, 2011 12:40 PM
    • Marked as answer by Lénárd Monday, August 8, 2011 1:42 PM
    Monday, August 8, 2011 12:40 PM

All replies

  • Hi,

    If the Xrm.page.context is unavailable to your application then in silverlight try us the code below:

     

    jj_ServerUrl = HtmlPage.Document.DocumentUri.ToString();

     You may also try:

    Application.Current.Host.Source.Host;


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    • Proposed as answer by Jehanzeb.Javeed Monday, August 8, 2011 12:40 PM
    • Marked as answer by Lénárd Monday, August 8, 2011 1:42 PM
    Monday, August 8, 2011 12:40 PM
  • Hi Lenard,

    you can use Silverlightutility.cs file given in SDK samples and use GetServerUrlFromContext()

    File Location

     ..\sdk\samplecode\cs\silverlight\restsilverlightcontacteditor\restsilverlightcontacteditor\utilities

     

     


    NarSr
    Monday, August 8, 2011 12:43 PM
  • Pass it as a querystring to the silverlight app.

    http://thepursuitofalife.com/getting-query-string-values-in-silverlight/

     

    I hope this helps


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Proposed as answer by Amreek Singh Monday, August 8, 2011 1:11 PM
    Monday, August 8, 2011 1:11 PM
  • The jj_ServerUrl = HtmlPage.Document.DocumentUri.ToString(); works!

    Thanks!

    Monday, August 8, 2011 1:43 PM