ASP.会话超时后,NET MVC 4应用程序数据库连接问题



我有一个使用。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

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

<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数据库,这就是为什么我在我的托管公司的服务器上使用数据库的连接字符串。

如果您在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" />

最新更新