This topic describes the steps you must perform to deploy your WCF RIA Services application to a Web server.
The .NET Framework 4 must be installed on the Web Server for a RIA Services application to work.
The RIA Services assemblies must be available on the Web Server. You can make them available on the Web Server by either including them in the Bin folder of your project or by installing them in the global assembly cache (GAC).
- Bin Deployment - when deploying your application, you can include the RIA Services assemblies in the Bin folder of your project. To do this, you must select in Visual Studio each reference that you want to include and must set the Copy Local property to True. After setting this value to True, the assemblies will be copied to the Bin folder the next time you build the solution. When the assemblies are copied to the Bin folder, they will be copied to the Web server when you publish the site.
GAC Deployment - instead of copying the RIA Services assemblies in the Bin folder of every project that uses them, you can install the assemblies in the GAC. Any assemblies in the GAC are available to every application on the server. This approach is easier to maintain because an assembly only needs to be updated in the GAC instead of every Bin folder.
To install the RIA Services assemblies in the GAC on a Web server, run the following command.
msiexec /i RiaServices.msi SERVER=TRUE
The Telerik Data Access assemblies must be available on the Web Server. You can make them available on the Web Server by either including them in the Bin folder of your project or by installing them in the global assembly cache (GAC). The needed assemblies are:
To deploy a WCF RIA service on IIS, the application that hosts it has to contain the appropriate **.SVC* file. To provide such, you can use the following steps:
- Open the application in Visual Studio
In the ClientBin folder of the service application, add a new WCF Service:
- Right-click on ClientBin and select Add > New Item... in order to run the Add New Item... dialogue.
Select the WCF Service template, provide a name for the file following demonstrated convention, and click OK:
[WebApplication name]-[Name of the domain service type].svc
In Solution Explorer expand the ClientBin folder and delete the following files:
- I[WebApplication name]-[Name of the domain service type].cs(vb)
- [WebApplication name]-[Name of the domain service type].svc.cs(vb)
Edit the .SVC file with the help of the XML editor and provide content similar to the following:
<%@ServiceHost language="C#" Debug="true" Service="Fullyqualified.Service.Name" Factory="System.ServiceModel.DomainServices.Hosting.DomainServiceHostFactory" %>
<%@ServiceHost language="VB" Debug="true" Service="Fullyqualified.Service.Name" Factory="System.ServiceModel.DomainServices.Hosting.DomainServiceHostFactory" %>
Select the .SVC file and open Properties Window for it. Set the Copy to Output Directory property to Copy always.
By default, all of these values are set in the Web.config file when you create a RIA Services solution in Visual Studio. If you deploy this Web.config file with any necessary changes to move from your development environment to the production environment, your RIA Services solution is properly configured. However, if you must retain an existing Web.config file, you will need to integrate the values for RIA Services. These values include the aspNetCompatibilityEnabled setting, the target framework, and the domain service definitions.
To set the aspNetCompatibilityEnabled property to true, include the following element in Web.config:
<system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel>
To set the target framework to 4.0, include the following element:
<compilation targetFramework="4.0" />
To define the domain service module, specify it in the <httpModules> and <modules> elements:
<system.web> <httpModules> <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </httpModules> </system.web>
<system.webServer> <modules runAllManagedModulesForAllRequests="true"> <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </modules> </system.webServer>
If you are using "Integrated Security=True" in your connection string for your "LocalSqlServer" connection (the connection to the database that your authentication service is using), then it is possible to have security issues when deploying your Silverlight application. When you are running the Silverlight application under Visual Studio 2010, the personated user is you, the current windows login user. But when you deploy the Silverlight application to IIS, unless you set a valid windows user as the user that your Application connects as, the personated user is the Network Service. In this situation there are two possible solutions:
- Add login for the "NT AUTHORITY\NETWORK SERVICE" to your server. After that give permissions for "NT AUTHORITY\NETWORK SERVICE" to the target database.
- Change the connection string to use SQL authentication instead of Windows authentication.