【问题标题】:ASP.NET MVC 4 Database ErrorsASP.NET MVC 4 数据库错误
【发布时间】:2013-02-27 08:19:01
【问题描述】:

我已将我的网站发布到虚拟主机,但我遇到了一些严重的数据库问题。这是我的错误

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.

Line 255:            <providers>
Line 256:                <add name="AspNetSqlMembershipProvider"
Line 257:                    type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Line 258:                    connectionStringName="LocalSqlServer"
Line 259:                    enablePasswordRetrieval="false"
Source File: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config    Line: 257 

这是到我的主机的连接字符串:

<connectionStrings>
    <remove name="LocalSqlServer" />
    <add name="SiteSqlServer" connectionString="Server=(localhost);Database=ulprojec_******-***;uid=ulprojec_***;pwd=********a;" />   

</connectionStrings>

这是我从微软网站获得的会员连接字符串,但它仍然导致第一个错误发生:

<membership defaultProvider="SiteSqlServer"
      userIsOnlineTimeWindow="15">
      <providers>
        <add 
          name="SiteSqlServer" 
          type="System.Web.Security.SqlMembershipProvider" 
          connectionStringName="SiteSqlServer"
          applicationName="georgi-it"
          enablePasswordRetrieval="false"
          enablePasswordReset="true"
          requiresQuestionAndAnswer="true"
          requiresUniqueEmail="false"
          passwordFormat="Hashed"
          maxInvalidPasswordAttempts="5"
          passwordAttemptWindow="10" />
      </providers>
    </membership>

我真的很感激任何帮助,因为我已经绝望了。

编辑:我整理出来了

我现在有这个问题:

Exception Details: System.ArgumentException: Invalid value for key 'attachdbfilename'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

【问题讨论】:

  • 你见过this吗?
  • 我假设您已经查看并且您的配置文件不包含字符串“attachdbfilename”?这听起来像是连接字符串的一部分。

标签: asp.net sql asp.net-mvc-4


【解决方案1】:

如果错误是您收到的错误,这意味着您在以下部分中使用了连接字符串“LocalSqlServer”:

<providers>
Line 256:                <add name="AspNetSqlMembershipProvider"
Line 257:                    type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
**Line 258:                    connectionStringName="LocalSqlServer"**
Line 259:                    enablePasswordRetrieval="false"

在这里,您正在删除连接字符串。

<connectionStrings>
    **<remove name="LocalSqlServer" />**
    <add name="SiteSqlServer" connectionString="Server=(localhost);Database=ulprojec_******-***;uid=ulprojec_***;pwd=********a;" />   

</connectionStrings>

我认为您可以看到连接字符串存在一个简单的命名问题。

【讨论】:

  • 是的,我想通了,但现在我有另一个问题
【解决方案2】:

如果您不使用会员功能,请从根 web.cofig 文件的 system.web 部分中删除会员、配置文件和角色管理器标签。这帮助我解决了这个问题。

【讨论】:

  • 究竟应该删除什么以及从哪里删除?
猜你喜欢
  • 2014-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-04
  • 1970-01-01
  • 1970-01-01
  • 2013-09-18
  • 1970-01-01
相关资源
最近更新 更多