herbrich19
Goto Top

Netzwerkbezogener oder instanzspezifischer Fehler beim Herstellen einer Verbindung mit SQL Server web.config

Hallo,

Ich wollte endlich mal das Login für herbrich.org zuende bauen. So, Happy! Ich bekomme die Fehlermeldung "etzwerkbezogener oder instanzspezifischer Fehler beim Herstellen einer Verbindung mit SQL Server..." so weit so gut. ABER: Diese Fehlermeldung ist Blödsinn weil deinitiv etwas mit der WebConfig nicht stimmt.

Ich benutze den Linq2SQL DataContext. Dieser lässt sich im zweifel mit einen ConnectionString selbst inizialisieren. Was ich entsprechend auch getan habe (www.herbrich.org/wget/1) und es funktioniert. Von Visual Studio aus ist der SQL Server genauso gut zu erreichen (localhost und 127.0.0.1 beides versucht) wie über sein Managmand Studio.

So, WGET Module konnte durch das Füttern des Connection String in sein DataContext wieder bereinigt werden von Fehler weil ab da ging es ohne Probleme. So, natürlich hat der ASP.NET Membership Provider kein DataContext den man direkt inizialisieren kann. Er braucht also den Connection String aus der Web.Config.

<?xml version="1.0" encoding="UTF-8"?>  
<!--
  Informationen zur Konfiguration Ihrer ASP.NET-Anwendung finden Sie unter
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />  
  </configSections>
  <connectionStrings>
    <clear />
    <add connectionString="Data Source=127.0.0.1;Initial Catalog=JenniFrame;Persist Security Info=True;User ID=sa;Password=1234" name="ApplicationServices" providerName="System.Data.SqlClient" />  
    <add connectionString="Data Source=127.0.0.1;Initial Catalog=JenniFrame;Persist Security Info=True;User ID=sa;Password=1234" name="Herbrich.JenniFrame.DataSources.My.MySettings.JenniFrameConnectionString" providerName="System.Data.SqlClient" />  
    <add connectionString="Data Source=127.0.0.1;Initial Catalog=JenniFrame;Persist Security Info=True;User ID=sa;Password=1234" name="wget.DataSources.My.MySettings.JenniferHerbrichConnectionString" providerName="System.Data.SqlClient" />  
  </connectionStrings>
  <system.web>
    <customErrors mode="Off" />  
    <authentication mode="Forms">  
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />  
    </authentication>
    <compilation debug="true" targetFramework="4.5.2">  
      <assemblies>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />  
      </assemblies>
    </compilation>
    <!--<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,\,?"/>--> 
    <pages enableSessionState="true">  
      <namespaces>
        <add namespace="System.Web.Optimization" />  
        <add namespace="Microsoft.AspNet.Identity" />  
      </namespaces>
      <controls>
        <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />  
      </controls>
    </pages>
    <membership>
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />  
      </providers>
    </membership>
    <profile>
      <providers>
        <clear />
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />  
      </providers>
    </profile>
    <roleManager enabled="true">  
      <providers>
        <clear />
        <add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />  
        <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" />  
      </providers>
    </roleManager>
    <!--
            Wenn die Bereitstellung in einer Cloud-Umgebung erfolgt, die über mehrere Webserverinstanzen verfügt,
            sollten Sie den Sitzungsstatusmodus aus "InProc" in "Custom" ändern. Ändern Sie 
            außerdem die Verbindungszeichenfolge namens "DefaultConnection" so, dass eine Verbindung mit einer Instanz 
            von SQL Server (einschließlich SQL Azure und SQL  Compact) anstatt mit SQL Server Express hergestellt wird.
      -->
    <httpCookies domain=".herbrich.org" />  
    <sessionState cookieless="UseCookies" cookieName="JHSSID" customProvider="DefaultSessionProvider" mode="InProc">  
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />  
      </providers>
    </sessionState>
    <globalization uiCulture="de" culture="de-DE" />  
    <machineKey decryptionKey="MashineKeyJenniJenni,IsolateApps" />  
    <!--<httpModules>
      <add type="Global.JenniferHerbrichRydelModule" name="JenniferHerbrichRydelModule"/> 
    </httpModules>-->
  </system.web>
  <system.webServer>
    <security>
      <!--<requestFiltering allowDoubleEscaping="true"/>--> 
    </security>
    <modules>
      <remove name="FormsAuthentication" />  
      <add type="JenniferHerbrichRydelModule" name="JenniferHerbrichRydelModule" />  
    </modules>
    <validation validateIntegratedModeConfiguration="false" />  
    <rewrite>
      <rules>
        <clear />
        <rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">  
          <match url="*" />  
          <conditions>
            <add input="{HTTP_HOST}" ignoreCase="true" pattern="www.herbrich.org" negate="true" />  
            <add input="{HTTP_HOST}" negate="true" pattern="jennifer.herbrich.org" ignoreCase="true" />  
            <add input="{HTTP_HOST}" negate="true" pattern="szagarus4.rauheshaus.net" ignoreCase="true" />  
            <add input="{HTTP_HOST}" negate="true" pattern="herbrich.diakonie-kropp.net" ignoreCase="true" />  
            <add input="{HTTP_HOST}" negate="true" pattern="jenniframe.kkh-wilhelmstift.de" ignoreCase="true" />  
          </conditions>
          <action type="Redirect" url="http://www.herbrich.org/{R:1}" redirectType="Permanent" appendQueryString="true" />  
        </rule>
        <rule name="Redirect all requests to https" stopProcessing="true">  
          <match url="(.*)" />  
          <conditions logicalGrouping="MatchAll">  
            <add input="{HTTP_HOST}" negate="true" pattern="jennifer.herbrich.org" ignoreCase="true" />  
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />  
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="true" />  
        </rule>
      </rules>
    </rewrite>
    <handlers>
      <!--<add name="robotx.txt" path="robots.txt" verb="GET" type="Herbrich.JenniFrame.Robots,JenniHerbrich" resourceType="Unspecified"/>--> 
      <!--<add name="robotx.txt" path="robots.txt" verb="GET" type="Herbrich.JenniFrame.Robots,JenniFrame" resourceType="Unspecified" />--> 
    </handlers>
    <httpErrors>
      <remove statusCode="404" subStatusCode="-1" />  
      <error statusCode="404" path="/errors/404.aspx" responseMode="ExecuteURL" />  
    </httpErrors>
    <httpProtocol>
      <customHeaders>
        <clear />
        <add name="Vary" value="Accept-Encoding,*" />  
      </customHeaders>
    </httpProtocol>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.24:00:00" />  
    </staticContent>
    <caching>
      <profiles>
        <add extension=".js" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="21:47:00" />  
        <add extension=".css" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="21:47:00" />  
        <add extension=".aspx" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />  
        <add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />  
        <add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />  
        <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />  
      </profiles>
    </caching>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />  
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />  
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />  
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />  
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />  
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />  
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" />  
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />  
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" />  
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />  
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" />  
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />  
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" />  
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />  
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />  
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />  
    </providers>
  </entityFramework>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />  
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />  
    </compilers>
  </system.codedom>
</configuration>

PS: Das Passwort ist auf 1234 zur Demo geändert worden. Ich habe mal die ganze Web.Config gepostet.

Content-Key: 5513228861

Url: https://administrator.de/contentid/5513228861

Printed on: April 27, 2024 at 12:04 o'clock

Member: sabines
sabines Jan 21, 2023 at 14:22:28 (UTC)
Goto Top
Moin,

deine Config habe ich mir nicht genau angeschaut, aber ein paar generelle Fragen und Infos habe ich für Dich:

Von wo aus versuchst Du auf den SQL Server zuzugreifen?
Ist das alles in einem lokalen Netzwerk?
Sind die Protokolle und Ports richtig defniert (SQL Konfigurationsmanager)?
Firewall hast Du im Blick?

Grüße
Member: Herbrich19
Herbrich19 Feb 02, 2023 at 03:56:52 (UTC)
Goto Top
Zitat von @sabines:

Moin,

deine Config habe ich mir nicht genau angeschaut, aber ein paar generelle Fragen und Infos habe ich für Dich:

Von wo aus versuchst Du auf den SQL Server zuzugreifen?
Ist das alles in einem lokalen Netzwerk?
Sind die Protokolle und Ports richtig defniert (SQL Konfigurationsmanager)?
Firewall hast Du im Blick?

Grüße

Hallo und guten Morgen,

Es liegt nicht am SQL Server. Ich habe den ConnectionString testweise hardcodiert an den DataContext im Konstruktor übergeben, und siehe da es funktioniert (https://www.herbrich.org/wget/1), nun habe ich aber zum Teil das Problem das ich einige DataContext Objekte in DLLs drinnen habe die wiederum MÜSSEN den ConnectionString aus der web.config beziehen.

LG, J Herbrich