Summary of Deploy WCF, Silverlight and ASP.NET

Published on Thursday, April 11, 2013

We posted 3 guides about Deploy a web application which includes WCF, SilverLight and ASP.NET , for simplified all steps, here provides a “quick guide”:

1: Make sure you have installed IIS successfully, at least you can visit http://localhost and see a default web page;

2: Open IIS Management (7 and above), right mouse click Sites\Default Web Site and choose “Add Virtual Directory”, here we create a virtual directory using a physical Widows path (you can make a new path here such as C:\ConspecWeb without leaving away IIS management tool), and give an alias name such as ConspecWeb;

3: Right mouse click the virtual directory that you just created in step 2, and choose Add Application, here we create a web application, we choose another physical path or create a new path, normally we will create a new sub path under the path that we created in step 2, for example: C:\ConspecWeb\WebTerminal, we give an alias name WebTerminal, and select Application Pool as ASP.NET 4.0;

4: Now copy the Website files (not WCF service files)  to C:\ConspecWeb\WebTerminal folder, and try to visit http:/localhost/ConspecWeb/WebTerminal, you should see the website home page (but just Silverlight page do not work since we have not set WCF yet), if no, then there must be some error places which you have not set correctly;

5: Go to the folder which you put the WCF service files, open the web config file, if your WCF hosted in a Windows application, the config file name should like  xxxx.exe.config; scroll down to Services section, most of content have already set for us, we just need to change the endpoint address to our real address:

– First, we set baseAddress as our WCF service root path, for our case, it is http://xxx.xxx.xxx.xxx/ConspecWeb/Services/;

– We have an endpoint for Client Access Policy file for the cross domain handling for Silverlight application, the address should be empty, means it uses the base address which we set above;

– We have basicHttpBinding endpoint to provide services to Silverlight clients, the endpoint address we set to "SL/";

– endpoint for Meta Data Exchange, we set to “SL/mex

so the final endpoint addresses will be set like following:

    <services>
      <service name="ServiceApp.Services.TerminalService" behaviorConfiguration="TerminalServiceBehavior" >
        <endpoint address="" behaviorConfiguration="webHttpBehavior" binding="webHttpBinding" bindingConfiguration="" name="PolicyEndpoint" contract="ServiceApp.Services.IClientAccessPolicy" />
        <endpoint address="SL/" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ConspecService" contract="ServiceApp.Services.ITerminalService"   name="TerminalServiceSLEndPoint"/>
        <endpoint address="SL/mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://192.168.1.230/ConspecWeb/Services/" />
          </baseAddresses>
        </host>
      </service>
    </services>

Note:

Sometimes when you use “localhost” and use another port number which is not 80, you might use the config similar with the following:

    <services>
      <service name="CCService.Services.CCServices">
        <endpoint address="http://localhost:8732/" behaviorConfiguration="webHttpBehavior" binding="webHttpBinding" bindingConfiguration="" name="PolicyEndpoint" contract="CCService.Services.IClientAccessPolicy" />
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ConspecService" contract="CCService.Services.ICCServices"   name="TerminalServiceSLEndPoint"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/MyServiceAddress/CCServices/" />
          </baseAddresses>
        </host>
      </service>
    </services>

after you done above, please try to visit the service URL, you should see the service information, if you can not see, there must be some wrong you have not set correctly yet;

6: Now set website Silverlight client, the process will be same as the description here; all other left steps also can be found in previous 3 blogs which we have posted.