Android Addicted Apps Creator

December 23, 2009

Deploying Silverlight WCF service from developement station to IIS

Filed under: Silverlight — alinberce @ 10:52
Tags: , ,

 

The beginnings…. 

I have created a Silverlight application that uses some data taken from an almighty SQL Server. To bring data I used Silverlight enabled WCF Services. The Visual Studio solution contains the Silverlight application project and the added Web site to display the Silverlight control.  The web application contains the WCF Service and the service is referenced in the Silverlight application project.

The Solution looks like this:

SilverlightWeb – the web application, contains a folder WCFServices in which I have Service.svc

SilverlightApp – Silverlight control that references Service.svc

When I ran the solution from within Visual Studio’s internal IIS server everything works fine, I can see the SQL data in the Silverlight control.

If I try to access the .svc file from the browser accessing the http://localhost:1487/WCFServices/Service.svc I can see a page with "You have created a service.", so it’s fine.

When I was ready with milestone one of the project I decided to give it a test-drive on the IIS production server . In order to deploy the solution to the IIS Production server I took the SilverlightWeb folder and copied it on the wwwroot folder. I created a Virtual Directory for SilverlightWeb folder. The .svc extension appears to be registered on the IIS. Before deploying I also modified the ServiceReferences.ClientConfig file, setting the endpoint address from

endpoint address="http://localhost:1487/WCFServices/Service.svc"

to

endpoint address="http://IIS Server’s IP address/WCFServices/Service.svc"

When I try to access from browser (http://IIS Server’s IP address/SilverlightWeb/TestPage.html), I can see the silverlight control, but when I press the button that calls the WCF Service nothing happens.

I tried to access the WCF service directly to see: http://IIS Server’s IP address/WCFServices/Service.svc  and gives me a File not found error

If I access using http://IIS Server’s IP address/SilverlightWeb/WCFServices/Service.svc I get a window where it says

<%@ ServiceHost Language="C#" Debug="true" Service="SilverligtWeb.WCFServices.Service" CodeBehind="Service.svc.cs" %>
 

The cursing…

In order to make the solution work on IIS I did everything I could find over the Google. I was really pissed off because WCF seemed such a fine concept but I couldn’t use it. It took me almost one week to find the answers… the good thing is that meanwhile I had other things to think about, rather than cursing. I have a straight rule: if it isn’t broken, don’t break it. Of course, the IIS server was fully used by a bunch of final users and I couldn’t risk making all kind of trial and error on it in order to make WCF service work. So, I made a full Backup and restore it on on PC. After all the hassle of restoring the image, driver install, network configuration… when everything was ready (took me 2 days) in 5 minutes I got the solution working. As my good friend, Emanuel said: It’s probably a 2 minute thing. Well, it was a simple thing. Emanuel also recommended me a great piece of software: Fiddler2. It is very useful to see what connections are being made from the browser, as it acts like a proxy between the browser and the network.

The solution…

Three baby steps were needed in order to solve the issue:

1.  Make sure that .Net 3 or 3.5 is installed on the IIS

2. Configure the IIS metabase to pass .svc files to ASP.NET and then on the WCF. The .svc was handled as static content.

Thank you Richard Blewett for these two steps.

3. A final step would be modifying the endpoint address (again) to be correct. When in Visual Studio internal IIS, there was no virtual directory created in order to run the project locally. When I deploy it on IIS I made a virtual directory so the endpoint address should be updated in order to have the correct path to .svc file.

endpoint address="http://IIS Server’s IP address/WCFServices/Service.svc"

to

endpoint address="http://IIS Server’s IP address/VirtualDirectoryMadeForSolution/WCFServices/Service.svc"

If still doesn’t work, please check to see if .svc extension is registered. If no, manually register it.

Well that’s all. I had to learn a little Silverlight. It is indeed a great technology that allowed me to make thing I could even think possible in a browser.

Advertisements

4 Comments »

  1. Congratulations!You maybe solved my problem too!

    Comment by Andrei Ignat — February 25, 2010 @ 07:53 | Reply

  2. Hi.

    Thanks to your article it became clear that the Silverlight application (Deploying Silverlight WCF) calls through the IP, no domain name.
    As I was unable to progress with the issue of crossdomain. I have two files in the root domain,(c:/inetpub/wwwroot/crossdomain.xml and c:/inetpub/wwwroot/ClientAccessPolicy.xml) but crossdomain continuous error. Any ideas. Thank you.

    Comment by Miguel Mayorga — June 8, 2010 @ 00:02 | Reply

    • Maybe try to put these files also in the Silverlight application folder? Also try to install Fiddler2 and access the site from internet explorer. You should see in Fiddler what connections are being made or tried.

      Comment by alinberce — June 8, 2010 @ 07:22 | Reply

  3. Hi,

    First thanks for the nice article which somehow summarizes all the relevant blogs out there.
    I’m having the same problem using silverlight 4 and IIS 7 running on Windows 7. Actually I did what you said and I feel .svc is not registered in my IIS. How can I check this? and if it is not registered how can I register it?

    I’m getting the following error message when I browse to “http://localhost/TestApp/WCFServices/Service.svc”

    Server Error in ‘/TestApp’ Application.

    This type of page is not served.

    Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension ‘.svc’ may be incorrect. Please review the URL below and make sure that it is spelled correctly.

    Requested URL: /TestApp/WCFServices/Service.svc

    Any ideas would be loved, and thanks.

    Comment by Ali — October 1, 2010 @ 12:06 | Reply


RSS feed for comments on this post. TrackBack URI

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

%d bloggers like this: