Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to write custom code to do this. There are two parts of the custom code: 1) The ASP.Net Silverlight Host site needs to pass the Silverlight Application the service address through an Initial Parameter; 2) The Application Start-Up event needs to process the initial parameters to point the service to the correct address. </p> <p><strong>Part 1 Code on the ASP.Net Host Site. There are 3 steps here:</strong></p> <p>A) Add a web.config value for containing the service name</p> <pre><code>&lt;appSettings&gt; &lt;clear/&gt; &lt;add key="MyServiceName" value="MyService.svc"/&gt; &lt;/appSettings&gt; </code></pre> <p>B) Get the webpage base address in in the page load event, append the service address to it, and save it to a page level variable</p> <pre><code> // Page level variable for initial parameters public string InitParams { get; set; } protected void Page_Load(object sender, EventArgs e) { var serviceAddress = ConfigurationManager.AppSettings["MyServiceName"]; var baseAddress = Request.Url.GetLeftPart(UriPartial.Authority); var fullAddress = string.Format("{0}/{1}", baseAddress, serviceAddress); // Pass parameters to SilverLight Application InitParams = string.Format( "{0}={1}", "ServiceAddress", fullAddress); } </code></pre> <p>C) In the page that hosts the silverlight control set the initial to the page level variable as defined in B.</p> <pre><code>&lt;object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"&gt; &lt;param name="source" value="ClientBin/MySilverlightProject.xap"/&gt; &lt;param name="onError" value="onSilverlightError" /&gt; &lt;param name="background" value="white" /&gt; &lt;param name="minRuntimeVersion" value="3.0.40624.0" /&gt; &lt;param name="autoUpgrade" value="true" /&gt; &lt;param name="InitParams" value="&lt;%=InitParams%&gt;" /&gt; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=3.0.40624.0" style="text-decoration:none"&gt; &lt;img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/&gt; &lt;/a&gt; &lt;/object&gt; </code></pre> <p>The key here being the </p> <pre><code>&lt;param name="InitParams" value="&lt;%=InitParams%&gt;" /&gt; </code></pre> <p><strong>Part 2 Hook the App start up event and initialize your service to the address in the App.xaml.cs file.</strong></p> <pre><code>private void Application_Startup(object sender, StartupEventArgs e) { string serviceAddress = e.InitParams["ServiceAddress"]; // INSERT CODE TO INITIALIZE YOUR SERVICE HERE } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload