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

杀马特。学长 韩版系。学妹 提交于 2019-12-13 04:12:04

问题


I'm currently setting up my website on a new SQL Server 2008 server, however I'm getting the following error:

 Configuration Error
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.

Source Error:

Line 158:        <roleManager>
Line 159:            <providers>
Line 160:                <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 161:                <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 162:            </providers>


Source File: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config\machine.config    Line: 160 

Why is this? And how can I resolve the issue? Thanks!


回答1:


Well I've never had to do this before on IIS6 and it seems unnecessary. For starters if you are to add a connectionString in the web.config called 'LocalSqlServer' it'll clash with the machine.config? So you have to remove the connection from the machine to add it to the web. This is what I've done as a temporary fix, but I've never seen this setup on IIS6 or IIS7 before.

As Steven said, you do a in that case, no need to modify the machine config for that.

There surely is another different between both computers for that to have happened. A couple:

  • you had a in the new server, and not in your original server
  • you are inheriting a from another config.



回答2:


You are missing a connection string in the <connectionStrings> section of you config file:

<connectionStrings>
    <clear />
    <add name="LocalSqlServer" connectionString="[your connection here]" />
</connectionStrings>


来源:https://stackoverflow.com/questions/3699109/parser-error-message-the-connection-name-localsqlserver-was-not-found-in-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!