询问者
Silverlight+wcf iis发布之后,无法访问数据库

问题
全部回复
-
在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文件如上,是数据库连接方面的2009年10月30日 8:24 -
你这里有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" />
你是用什么访问数据库的?2009年10月31日 5:09 -
2009年11月2日 7:21
-
你好,
首先建议你在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.2009年11月2日 8:58 -
我今天试验了一下,在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.2009年11月4日 9:36 -
可以看一下发布后的具体错误。猜测可能是跨域访问的问题。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>2009年11月18日 8:50