ConfigurationManager.ConnectionStrings [0]. Returning LocalSqlServer Name

I have a WCF web service and I call the WCF method with Ajax( JQuery).

I tested my web service with WcfTestClient.exeand it works well.

But when I call the web service method with JQuery, I have an error (the reference to the object is not installed in the object instance ).

I am debugging, and I have it in mine **ConfigurationManager.ConnectionStrings[0].Name** : *LocalSqlServer*.

My DataBase key is RMS, not LocalSqlServer.

I have 2 projects in my solution, WCF and an application console that will do to return the web service.

Here is my solution

enter image description here

Here is my 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. ?

+4
2

.

app.config GettingStartedHost, .

?

+1

, , :

<clear />

:

 <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" />

: machine.config . LocalSqlServer. Clear .

+7

Source: https://habr.com/ru/post/1530967/


All Articles