Silverlight+wcf iis发布之后,无法访问数据库
- 我用一个工程的website+wcf发布没有问题,可以正常访问数据库。但是Silverlight+wcf 使用iis发布后,也就是两个工程,一个是silverlight客户端工程,另一个就是wcf数据层工程,这样无法访问数据库没有错误提示,就是本来在vs2008里调试打开页面可以看到数据库中的数据,经过iis发布之后,数据库中的数据不能显示,也就是无法连接到数据库,这是什么原因。本人刚接触wcf,请高人指点一下。谢谢
- 已编辑爬完落地 2009年11月2日 1:04
全部回复
- 在iis不能用本机帐号登陆 只能用sa模式登陆
你检查链接数据库字符串 和wcf地址正确 在iis不能用本机帐号登陆 只能用sa模式登陆
你检查链接数据库字符串 和wcf地址正确
<?xml version="1.0"?>
<!--
メモ: このファイルを手動で編集する代わりに、Web 管理ツールを使用
してアプリケーションの設定を構成することができます。Visual Studio
の [Web サイト] メニューにある [ASP.NET 構成] オプションから設定
を行ってください。設定およびコマンドの一覧は、通常
\Windows\Microsoft.Net\Framework\v2.x\Config にある
machine.config.comments で確認できます。
-->
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings/>
<connectionStrings>
<add name="SL_DBConnectionString" connectionString="Data Source=KANAGAWA27\SQLEXPRESS;Initial Catalog=SL_DB;Persist Security Info=True;User ID=sa"
providerName="System.Data.SqlClient" />
<add name="SLSampleConnectionString" connectionString="Data Source=WZH-F63D843AAC0;Initial Catalog=SLSample;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="SL_DBConnectionString1" connectionString="Data Source=KANAGAWA27\SQLEXPRESS;Initial Catalog=SL_DB;Persist Security Info=True;User ID=sa;Password=sasql"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
web.config文件如上,是数据库连接方面的- 你用什么版本sqlserver 如果是vs集成sqlserver的话 只能在vs中使用
你用什么版本sqlserver 如果是vs集成sqlserver的话 只能在vs中使用
我用的是sql server2008- 如果数据库在访问中没有出现异常的话 那就是正常了
剩下wcf地址是否正确 如果你用了绝对路径 那访问不到wcf了 - 谢谢楼上,但是我想问一下,怎么写可以访问到wcf呢
- string urls= System.Windows.Browser.HtmlPage.Document.DocumentUri.AbsoluteUri;
int o = urls.LastIndexOf("/");
string url = urls.Substring(0,o + 1);
用代码写wcf 绑定+地址 比如 url+wcf文件 - 我看网上有人说权限设定的问题,我不知道是什么原因
你这里有3个connection:
<add name="SL_DBConnectionString" connectionString="Data Source=KANAGAWA27\SQLEXPRESS;Initial Catalog=SL_DB;Persist Security Info=True;User ID=sa"
providerName="System.Data.SqlClient" />
<add name="SLSampleConnectionString" connectionString="Data Source=WZH-F63D843AAC0;Initial Catalog=SLSample;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="SL_DBConnectionString1" connectionString="Data Source=KANAGAWA27\SQLEXPRESS;Initial Catalog=SL_DB;Persist Security Info=True;User ID=sa;Password=sasql"
providerName="System.Data.SqlClient" />
中间的应该是Sql Server,但是你应该提供用户名和密码, 例如:
另外的两个是SqlExpress.需要指定database文件名,以及你要确认IIS里这个程序下的App_Data 文件夹设成可读写权限
<add name="NORTHWNDConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" />
你是用什么访问数据库的?- 我是用linq to sql 访问数据库的
如果不发silverilght的访问代码
只能猜测 很难找到问题- 我用一个工程的website+wcf发布没有问题,可以正常访问数据库。但是Silverlight+wcf 使用iis发布后,也就是两个工程,一个是silverlight客户端工程,另一个就是wcf数据层工程,这样无法访问数据库没有错误提示,就是本来在 vs2008里调试打开页面可以看到数据库中的数据,经过iis发布之后,数据库中的数据不能显示,也就是无法连接到数据库
- 无法确定你的问题根本在哪
第一 wcf在iis上没有映射svc扩展名
第二 wcf地址在iis中错误
第三 如果你访问不到wcf 那就访问不到数据库
另外你说的很清楚 可是太抽象了 - 你好,我对wcf是刚了解的,
第一个有发布后,有svc扩展名
第二 发布后,运行没有错误,你说的wcf地址我不太明白,指的是什么
第三 如何访问wcf
不好意思,我对wcf发布不是很了解。wcf也是刚接触。能具体说说吗 - 你好,
首先建议你在WCF里简单返回一个string来测试是否能够在发布后在Silverlight程序中成功调用到WCF里面.如果这步成功了,根据你说的"website+wcf发布没有问题,可以正常访问数据库", 请检查一下配置的连接字符串和访问数据库的代码等等有区别没有,再一步步找原因.
Please remember to mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework http://cfx.codeplex.com/! If you have any feedback, please tell us. - 我今天试验了一下,在wcf中返回一个简单的字符串,结果vs2008运行可以返回,在iis发布后,返回的地方,网页出错,也就是访问不到wcf,请问这种情况如何解决。
我今天试验了一下,在wcf中返回一个简单的字符串,结果vs2008运行可以返回,在iis发布后,返回的地方,网页出错,也就是访问不到wcf,请问这种情况如何解决。
你把wcf相关代码和配置文件发来 还有你的iis网站访问地址 帮你修改怯怯的问一声,你在服务器上enable WCF了吗? 你deploy的是Web Application吗? 错误页面怎么说的?
我今天试验了一下,在wcf中返回一个简单的字符串,结果vs2008运行可以返回,在iis发布后,返回的地方,网页出错,也就是访问不到wcf,请问这种情况如何解决。
你好,
你不是说"website+wcf发布没有问题,可以正常访问数据库"吗?是在同一台机器上的吗?"website+wcf"的那个WCF能够正常工作吗? 最后请提供详细的错误信息以便分析问题.
Please remember to mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework http://cfx.codeplex.com/! If you have any feedback, please tell us.- 大家好!这个问题解决没有啊?我也同样遇到这个问题,而且很久了。希望搞定了,可以共享一下解决方法·····
Thanks for any help! - 可以看一下发布后的具体错误。猜测可能是跨域访问的问题。clientaccesspolicy.xml文件放在iis发布的根目录下,内容如下。
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>

