【发布时间】:2014-04-13 11:35:46
【问题描述】:
我有一个 WCF Web 服务,我使用 Ajax (JQuery) 调用 WCF 方法。
我用WcfTestClient.exe 测试了我的网络服务,它运行良好。
但是当我使用Jquery 调用 Web 服务方法时,出现错误(对象引用未设置为对象的实例)。
我进行调试,我的 **ConfigurationManager.ConnectionStrings[0].Name** : *LocalSqlServer* 中有这个。
我的数据库键是 RMS 而不是 LocalSqlServer。
我的解决方案中有 2 个项目,即 WCF 和一个应用程序控制台,用于关闭 Web 服务。
这是我的解决方案
这是我的 web.config :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="RMS" connectionString="Data Source=192.168.40.137;Initial Catalog=RMS_Database;Persist Security Info=True;User ID=****;Password=****"
providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="16384"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
我创建了一个.asmx 网络服务,并成功调用了JQuery。
我认为我的解决方案没有使用正确的web.config. 如何解决这个问题?
【问题讨论】:
标签: c# jquery asp.net web-services wcf