简体   繁体   中英

How to publish Silverlight site using a domain service?

I have a Visual Studio 2010 solution with 2 projects. One is a Silverlight client, the other a web site to which I added a domain service. It works fine when debugging in Cassini, but when I publish to IIS I get nothing returned from my entity query.

I'm not even sure where to start as this is my first attempt at doing this.

A few things:

Developing on Cassini (don't do it if you can avoid it)

It's always better to develop against IIS itself. There are differences between IIS and Cassini which can bite you if you aren't aware of them and it just makes more sense; you should always develop as close to the environment that you are develping for. Unless you are deploying to Cassini (and you aren't, no one does) then there's no point in developing against it unless you simply can't (you don't have a local install of IIS).

Web Deploy

Install Web Deploy on the IIS server you are going to deploy to. Once you do that, you can right click the web/domain project in your solution and select "Build Deployment Package".

Then, you will get a package that you can use with Web Deploy which will deploy everything (Silverlight, ASP.NET components, etc, etc) your project to IIS with a simple command-line call.

Deploying to IIS might have some issues. I'd like to see what errors messages you're getting. Without these information it will become pretty difficult to give you an advice.

PS: I'm gonna assume that your WCF RIA services have valid definition ;-).

Based on my experience, this is the minimum config file, but it certainly will require more settings if you're consuming Authentication Domain Services or Data domain services (such as LinqToEntities or LinqToSql domain services):

Make sure your IIS have all the sections required by WCF RIA

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="system.serviceModel">
      <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <system.web>

  <!-- You might need identify tag if you app requires additional permission to run -->

  <!-- See you want to see more details when a error happens -->
  <customErrors mode="Off"/>
  <compilation debug="true" targetFramework="4.0" />

  <!-- If your application uses authentication and authoriztion then -->
  <!-- Elements required required for authentication: authentication and membership and probably roleManager -->


<httpModules>
      <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler"
          type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
  </system.webServer>

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

</configuration>

Make sure the WCF RIA services are up and runnning Try to access the WCF RIA service by using a web browser. Usually the service you're exposing has format like:

http://[hostname]/[namespacename]-[classname].svc

So, you should be able to hit the URL and see an output like: 在此处输入图片说明

Make sure DLLS are available There are two options to deploy the WCF RIA dlls in the server side. You can indicate to the application that DLLs should be copied into the bin folder of your application or you can run the WCF RIA installer in server mode.

Accessing the services from the client If the services are up and running they should be reachable to your Silverlight client. If there is an error you can start tracing by enabling WCF RIA debugging. See http://blogs.msdn.com/b/saurabh/archive/2010/03/16/ria-services-application-deployment.aspx for more details about it.

This was a very stupid, newbie issue. I used SQL Server Profiler to watch the queries come in and realized the account being used to authenticate against SQL Server was the server's computer account. I secured the Domain Service's methods and allowed the computer account access tot he DB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM