本文介绍了LocalSqlServer没有被发现在应用程序的配置或连接字符串是空的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我刚刚升级了.NET 3.5的MVC 1个项目到.NET 4.0的MVC 3出于某种原因,现在当我尝试运行它,它说LocalSqlServer中未找到连接名该应用程序的配置或连接字符串是空的。。我不知道为什么它这样做,因为没有在那里我的code它寻找一个 LocalSqlServer 连接字符串,如果我把一个 LocalSqlServer 在我与我的标准连接字符串的值配置文件中的连接字符串,并尝试去到网站,它带我到了请登录网址,但有404页(和没有自定义404页面要么)

I've just upgraded a .NET 3.5 MVC 1 project to .NET 4.0 MVC 3 and for some reason now when I try to run it it says The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.. I'm not sure why it does this as no where in my code does it look for a LocalSqlServer connection string, and if I put in a LocalSqlServer connection string in my config file with the value of my standard connection string and try to go onto the website, it takes me to the 'please log in' URL but with a 404 page (and not the custom 404 page either)

任何人都知道这个问题可能是什么?

Anyone know what the problem could be?

问候,
哈利

推荐答案

在LocalSqlServer连接字符串在Machine.config中定义的。

The LocalSqlServer connection string is defined in your Machine.config.

如果你没有一个默认的Machine.config文件,它可能已被删除。这样,你会需要自己的Web.config里面重新添加。

If you don't have a default Machine.config file, it might have been removed. You would then need to re-add it inside your own Web.config.

我的LocalSqlServer:

My LocalSqlServer:

<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>

您可以在这里找到你的machine.config中:

You can find your machine.config here:

C:\Windows\Microsoft.NET\Framework\[FRAMEWORK VERSION]\CONFIG\machine.config

这篇关于LocalSqlServer没有被发现在应用程序的配置或连接字符串是空的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 13:19