网站在我的本地计算机上运行完美,连接字符串包含已托管服务器的数据库信息。但是当我在服务器上传网站时,我收到此错误。网站的主页面正在加载,但其他具有sql连接可访问性的功能不是。
System.ComponentModel.Win32Exception:拒绝访问
发生与网络相关或特定于实例的错误 建立与SQL Server的连接。找不到服务器或 无法访问。验证实例名称是否正确 SQL Server配置为允许远程连接。 (提供者:SQL 网络接口,错误:56 - 无法加载SQLUserInstance.dll 从注册表中指定的位置。验证本地 SQL Server Express的数据库运行时功能是正确的 安装。)]
我的本地默认连接字符串是
<add name="defaultconnection" connectionString="Data Source=(LocalDb)\mssqllocaldb;Initial Catalog=aspnet-fuzzzz-20160406102902;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-fuzzzz-20160406102902.mdf" providerName="System.Data.SqlClient" />
除此之外,我有实体框架模型连接字符串,其中包含包含数据的远程服务器的sql身份验证..
修订及补充资料 - 我的过滤器看起来像这可能是服务器默认采用我的默认连接字符串而不是我的实体框架连接字符串
public SimpleMembershipInitializer()
{
Database.SetInitializer<UsersContext>(null);
try
{
using (var context = new UsersContext())
{
if (!context.Database.Exists())
{
// Create the SimpleMembership database without Entity Framework migration schema
((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
}
}
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
}
}