开发者

Remote database connection fails when web site is deployed

I created a database using GoDaddy's online database manager, but I can't query it once I deploy my ASP.NET project. On my local machine, everything works fine. I have a data grid that is filled with data.

Here are the steps I followed to query the database from my local machine:

  • Create a Silverlight application. Host the SL project in an ASP.NET web application. Enable WCF RIA services
  • Add a new entity model to the ASP.NET project. Entity connection string points to the remote database
  • Add a domain service to the ASP.NET project
  • Add a data grid to the Silverlight project by using the Data Sources tab on the left hand side

When I run the app, I can fill the grid with data on my local machine. When I FTP-deploy it using the Publish Web wizard, the app is successfully uploaded as I can see the files through an FTP app.

What am I doing wrong? I heard that SL applications need a clientaccesspolicy.xml file. Is it needed when WCF RIA services are used? Do I need to change my Web.config file? Here is the VS auto-generated config file:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler"
        type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServi开发者_C百科ces.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <system.web>
    <httpModules>
      <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </httpModules>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <connectionStrings>
    <add name="(Entities Here)" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=(Source Here);Initial Catalog=(Catalog Here);User ID=(ID Here);Password=(Password Here);MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
</configuration>


I heard that SL applications need a clientaccesspolicy.xml file. Is it needed when WCF RIA services are used?

Yes. You have to explicitly allow cross domain access. It worked locally as your web site and database server were on the same "domain" - your local machine.

The clientaccesspolicy.xml file must be in the root directory of the domain where the service is hosted.

You can also use crossdomain.xml - Silverlight supports both.

Source

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜