0

我有一个使用 .NET 框架 4.5 的 MVC 4 网站,起初可以正常工作。它允许我登录并进行我的业务添加、删除和编辑记录。因此,它显然最初是在没有问题的情况下连接到数据库的。但是,如果我让它暂时处于非活动状态并稍后再回来,然后单击指向显示数据库中数据的页面的链接,我会收到以下错误:

The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider cannot automatically create the database file.

该网站在我的本地主机上运行良好,但在我在线托管时却不行。我为此使用共享主机。我在网上进行了广泛的搜索,发现很多人都遇到了同样的错误,但他们似乎没有一个网站最初可以正常工作,然后突然停止工作。我在网上找到的解决方案大致如下:

add these two lines to your web.config file
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=p3swhsql-v15.shr.phx3.secureserver.net; Initial Catalog=DatabaseName; User ID=****; Password='****';"/>


by default the .net site is trying to find your database in the local filesystem in this case would be the app_data subfolder under the wwwroot directory. simply removing the connectionstring and replacing it with the database connection solves the issue. My example utilizes an SQL db on godaddy's server. however i'm sure you can replace the connection string with the appropriate string for your connection. good luck and i hope this helps anyone that may be having this issue

我的程序似乎在做的是在我第一次登录时使用在线数据库,然后在会话超时后恢复尝试使用本地文件系统中的数据库。这非常令人沮丧。我的 web.config 文件如下所示:

<connectionStrings>
    <remove name="DefaultConnection"/>
    <add name="DefaultConnection" connectionString="Data Source=winsqls01.cpt.wa.co.za;Initial Catalog=SportFantasySA;Persist Security Info=True;User ID=*****;Password=*****" providerName="System.Data.SqlClient"/>
  </connectionStrings>

请帮忙。我很想得到这个工作。我知道它无法在托管空间中创建 sql express 数据库,这就是为什么我在托管公司的服务器上使用数据库的连接字符串。

4

1 回答 1

0

如果您将它托管在 Godaddy 上,请选择连接字符串

<providers>
<remove name="AspNetSqlMembershipProvider" />
<add name="AspNetSqlMembershipProvider" connectionStringName="LocalSqlServer"
    ..other attributes here... /></providers>

<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
    connectionString="Data Source=xxxx; Initial Catalog=xxx; User ID=xxx; Password=xxx;"
    providerName="System.Data.SqlClient" />

于 2013-06-19T10:40:34.313 回答