c# - ASP.Net在登录时引发错误-建立与SQL Server的连接时发生与网络相关或特定于实例的错误

标签 c# sql-server compiler-errors runtime-error membership

我的主机上有一些页面(Web表单),这些页面可从MSSQL服务器检索一些信息并可以正常运行,但是我的问题是我的“登录”页面。
在我的登录页面中,当用户输入错误的用户名或密码时,表单正常运行并向用户显示相关消息,但是如果正确输入用户名和密码,则会引发附件错误。

我认为这与“成员资格”有关,但我不知道。这是我的“web.config”文件:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="JahanPay.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <applicationSettings>
    <JahanPay.Properties.Settings>
      <setting name="JahanPay_com_jahanpay_Webservice2ControllerService"
          serializeAs="String">
        <value>http://jahanpay.com/webservice2/index?ws=1</value>
      </setting>
    </JahanPay.Properties.Settings>
  </applicationSettings>
  <connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=127.0.0.1;Initial Catalog=ASPNETDB;Integrated Security=False;User ID=something;Password=something;Connect Timeout=15;Encrypt=False;Packet Size=4096" />
  </connectionStrings>
  <system.web>
    <roleManager enabled="true" defaultProvider="SqlProvider" >
        <providers>
            <clear/>
            <add name="SqlProvider" type="System.Web.Security.SqlRoleProvider"
              connectionStringName="ConnectionString" applicationName="/" />
        </providers>
    </roleManager>
    <authentication mode="Forms" >
      <forms loginUrl="users/signin.aspx" timeout="30"></forms>
    </authentication>
    <compilation debug="true" targetFramework="4.0"/>
    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ConnectionString" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Hashed" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="4" applicationName="/" />
      </providers>
    </membership>
    <profile>
      <properties>
        <clear/>
        <add name="username"/>
        <add name="userfamily"/>
        <add name="companyname"/>
        <add name="sex" type="boolean"/>
        <add name="mobile"/>
        <add name="birthday"  type="DateTime"/>
      </properties>
    </profile>
    <customErrors mode="Off"/>
  </system.web>
  <location path="userpanel">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="ServiceAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
        multipleSiteBindingsEnabled="true" />
    <services>
      <service name="Service">
        <endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior"
            binding="webHttpBinding" contract="Service" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

A network-related or instance-specific error occurred

我该怎么办?

再一次,因为我认为很重要,所以我提到只有在用户尝试使用正确的用户名和密码登录时才会发生。

最佳答案

您的SQL Server无法访问。如果通过网络连接,请尝试ping服务器。如果sqlserver应该在您的PC上,请尝试重新启动sqlserver。

关于c# - ASP.Net在登录时引发错误-建立与SQL Server的连接时发生与网络相关或特定于实例的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33212830/

相关文章:

sql-server - SQL Server 2008 - 如何从表值函数返回用户定义的表类型?

c++ - 得到这个错误: request for member 'at' in 'array3' , which is of pointer type

c++ - 错误 : ‘int’ is not a class, 结构或 union 类型`

c# - 如何在 LINQ 查询中按月分组?

c# - 在 RichTextBox WPF 中添加图像

sql - SQL中如何替换字符

java - 为什么编译器会说如果变量需要在循环中才能通过,则可能不会对其进行初始化?

c# - Compact Framework/Threading - MessageBox 在选择选项后显示在其他控件之上

c# - 抽象工厂模式——具体工厂的要点

mysql - 使用 MSSQL 数据库和 MySQL 数据库