【发布时间】:2014-07-10 18:53:23
【问题描述】:
我是 WCF 的新手,我已经创建了一个 wcf 服务和一个要使用 LINQ 写入的数据库。在我的 web.config 文件中它仍然使用标准连接字符串(我不太了解连接字符串的内容)
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\jarvis.mdf;Integrated Security=True"
创建数据库时自动生成。我的 WCF 接口具有以下操作合同:
[WebGet(UriTemplate = "Add", ResponseFormat = WebMessageFormat.Json)]
string Add();
当我在本地机器上使用"http://localhost:58632/WCFService.svc/Add" 运行 WCF 时,我完全没有问题地写入数据库。(可能是因为连接字符串用于本地连接)
当我尝试在 IP 为 10.0.0.14 的服务器上部署应用程序并运行 http://10.0.0.14/Service/WCFService/Add 时,它不允许我写入数据库。我认为这是因为连接字符串,但我不确定。
我在 IIS 上部署的过程是"
1. Right click on the solution and select Publish...
2. Select Connection and the publish Method is Web Deploy Package
3. I go to the Package location and go in to the zip file to get the content.
4. Place the content in the wwwroot/Service folder, then I attempt to write.
当 WCF 部署在 IIS 上并且必须在运行 WCF 的服务器上安装 SQL Server 时,我将如何更改连接字符串以便可以写入数据库?我不想使用外部库或应用程序,例如 SlowCheetah。
【问题讨论】:
标签: c# database wcf iis visual-studio-2013