Deploying Silverlight WCF RIA Services on IIS 6

OK so you’ve just created a great Silverlight application, it works like a charm and it has come time to finally deploy. That should be the easy part.. think again!

Tim Heuer has a great post on his blog about this http://timheuer.com/blog/archive/2009/12/10/tips-to-deploy-ria-services-troubleshoot.aspx. If you search Google you will find tons of people with RIA deployment issues, however if you were like me you have to really sift through it to find any information that relates to your situation. Before reading the following make sure you have read Tim’s post and installed the RiaServices.msi with the server flag as noted. This will place the RIA DLL’s into your global assembly cache so that all applications running on the server have access to the files.

With RIA and IIS 6 you want to look for a few gotchas, once you know them they are easy. To find these you will first need to download a great piece of software called Fiddler (Google it) and whilst running fiddler, open your favourite browser and try to run your Silverlight application.

Now at this point you may get a 404 Not Found error shown in Silverlight. That doesn’t mean much as you may need fiddler to see the exact exception. Check the request for the web service in fiddler, copy the URL and load it into your browser. If you still get a 404 then most likely something is disallowing you from accessing the generated WCF service. Otherwise you should get an exception which well help you identify the source of your problem (your one of the lucky ones).

If you still cannot access the web service its time to try the web.config file. RIA services uses WCF in the back-end (The WCF services are dynamically generated) and as such you will need

<serviceHostingEnvironment 
     aspNetCompatibilityEnabled="true"
     multipleSiteBindingsEnabled="true" />

in your web.config. An easy way to do this (and add the appropriate references to RIA DLL’s is to create a new DomainService in your application and then simply delete it. Visual studio will handle all of the work for you. Reload your Silverlight app and try again.

If you are sure all of this is working next check your IIS virtual directory and ensure that the mapping extension .svc is mapped to the aspnet_isapi for which .NET framework you are using. To check this go to the properties of your virtual directory and click on the “Configuration…” button on the “Virtual Directory” tab. Make sure that when you update the mapping for .svc you UNCHECK the “verify file exists” check box. This is a very important step as the WCF service is dynamically served and does not exist on the file system. You should be able to find your asp.net_isapi should be able to be found in C:\Windows\Microsoft.NET\Framework\[Version]\aspnet_isapi.dll.

If you are still having issues getting to your RIA service at this point I would check the isapi wildcard extension. This is also a very important step, I have been caught out with this one way too many times. Ensure that the wildcard extension if any points to the correct aspnet_isapi and that the “verify file exists” checkbox is again UNCHECKED.

At this point your IIS virtual directory should be serving your WCF services, your web.config should allow WCF and RIA to do its thing and your RIA dll’s are in the GAC ( try copy local if cannot find the dll’s). By now if you still have problems post them in the comments. You could try manually creating the “.svc” files which map to their RIA domain service counterparts as a temporary solution.

Hopefully by now you’ve got the problem fixed and this post may have saved you a little time. If It has or you would like to point out more tips or correct something I have said please leave a comment

Advertisements

8 thoughts on “Deploying Silverlight WCF RIA Services on IIS 6

  1. Pingback: Silverlight: Deploying Silverlight on IIS 6 (Mime Types) « Refactor(this)

  2. I have a unique situation… followed all the steps on many posts like this one.. and I have had some luck… managed to get one of my wcf ria services working in IIS 6 by creating the SVC file manually. However, I have another wcf ria service that will not work after creating the SVC file manually. Fiddler continues to show 404 for that file… very frustrating and strange.

    • Never mind my post… it always helps to COPY ALL CHANGED FILES when deploying to your production server… that one hurts… thought all my changes were contained to XAP files… nope!

      Cheers… great article… sorry to muddy it up with my madness.

  3. I was extremely pleased to uncover this page.
    I wanted to thank you for your time due to this fantastic read!
    ! I definitely loved every bit of it and I have you book marked
    to look at new information on your blog.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s