post icon

Silverlight Tip of the Day #29 – Configuring Service Reference to Back to LocalHost

If your application leverages a Silverlight-enabled WCF service you may at times want to toggle the address to be pointing from the WCF service published and running on your server back to localhost in case you want to make modifications that you want to run and debug locally.

However, when pointing it back to localhost you might be stumped as to what port needs to be used. One easy way to determine this is to right click on your svc file in your web site, choose “Browse With”, select a browser and click the “Browse” button.

In your browser, copy the address from the address bar. This is the localhost address including the port you will want to configure your Silverlight service reference to point to. It will look like this:

http://localhost:21047/MyService.svc 

Thanks,
–Mike

3 Comments

Leave a comment
  1. Bigsby
    10. Jun, 2010 at 9:38 am #

    The used port is also on Web Application Project Properties on Web vertical tab. It is dynamically set but you can set it manually.

  2. Snowman
    10. Jun, 2010 at 7:39 pm #

    Ah, yea, I found it thanks!

  3. Josh Einstein
    11. Jun, 2010 at 6:38 am #

    Here’s another awesome tip… if your web service is hosted on the same server that is serving your Silverlight application, you can use a relative (to the xap) path to the WCF service. You’ll have to make this change in your ServiceReferences.clientconfig manually and you might get some IDE errors when refreshing the service reference but it works great at runtime.

    (not sure how to post XML here…)

    (client)
    (endpoint name=”BillingDataEntryService”
    address=”../Billing.svc”
    binding=”basicHttpBinding”
    bindingConfiguration=”secureHttp”
    contract=”Models.BillingDataEntry.BillingDataEntryService” /)
    (/client)