2013-04-03 44 views
0

带有使用表单身份验证的帐户控制器的默认ASP.NET MVC 4项目,但此身份验证在我的服务器上的IIS 7.5上出现此错误。Internet应用程序

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.) 

我该如何解决这个问题,因为我找不到类上的任何连接。

+0

你真的建立了一个数据库吗?你用什么连接字符串? – levelnis 2013-04-03 20:53:32

回答

1

默认的MVC 4项目依托IIS Express和的LocalDB,将产生的LocalDB存储在App_Data文件夹。

但是改变项目下建议您切换到使用的SQL Express完整的IIS运行时。为此,您需要创建一个数据库并设置相关的连接字符串。假定您的应用程序具有相关权限,并且WebSecurity.InitializeDatabaseConnection将autoCreateTables设置为true,则会自动创建相关表。

默认的数据库初始化是通过InitializeSimpleMembershipAttribute完成的,我们可以在Filters/InitializeSimpleMembershipAttribute.cs中找到,然后这个属性被应用到AccountController。

+0

我的问题是EntityFramework与此连接不兼容。 – 2013-04-04 17:08:13

0

您应该检查异常消息中建议的Windows日志。连接字符串位于Web应用程序的web.config文件中。

+0

但是,这是在本地主机上,并在web.config 唯一连接“DefaultConnection”,我真的不知道登录数据存储在哪里。 – 2013-04-03 21:01:55

+0

现在好了,我使用默认连接找到了WebSecurity.InitializeDatabaseConnection。现在我正在尝试调试下一步。 – 2013-04-03 21:28:20

相关问题