System.Data.SqlClient.SqlException: - ASP.NET MVC 4 C#中使用默认SimpleMembership,错误Internet应用程序模板用户登录失败XXX [英] ASP.NET MVC 4 C# - Internet Application Template using default SimpleMembership, Error: System.Data.SqlClient.SqlException: Login failed for user xxx

查看:356
本文介绍了System.Data.SqlClient.SqlException: - ASP.NET MVC 4 C#中使用默认SimpleMembership,错误Internet应用程序模板用户登录失败XXX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地运行的应用程序(本地主机),因为我已经注册了,我正常登录,然后可以通过我的应用程序的所有页面定时导航。然后在不注销,我关闭IIS前preSS。但是,当我再次启动IIS前preSS和调试再次从Visual Studio我的应用程序,以下错误显示在我的浏览器:
在'/'应用程序异常详细信息服务器错误:System.Data.SqlClient.SqlException:用户登录失败'XXX'。的'xxx'是我的SQLSERVER管理员名称。所以,如果我正确地理解它,因为我还没有从我的previous访问登出,它试图用我的SQL Server管理员凭据登录。

I am running the application locally (localhost), and since I have already registered, I log in properly and then can navigate regularly through all the pages of my application. Then without logging out, I close the IIS express. But when I start again the IIS Express and debug again my application from Visual Studio, the following Error is displayed in my browser: " Server Error in '/' Application. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'xxx'.". Where 'xxx' is my administrator name for sqlserver. So if I have understood it properly Since I have not logged out from my previous visit, it tries to log in with my SQL Server administrator credentials.

另一件事是,如果我将运行从其他浏览器我的应用程序是没有问题的,因为它显示应用程序,而无需已经有人登录,那么我登录这个浏览器上(第二个)具有相同USENAME我在第一个浏览器做了(重新启动IIS前preSS之前)并刷新第一个浏览器并重新开始工作(记录在我的第一个方法的用户名重新启动IIS前preSS之前)。

Another thing is that If I will run my application from another browser there is no problem since it displays the application without someone having already logged in, then I am logging in on this browser (second one) with the same usename as I had done in the first browser (before restarting the IIS Express) and refresh the first browser and starts to work again (logged in with the username of my first approach before restart IIS Express).

此外,当我在URL中使用我的IP,而不是本地主机,这个问题没有出现。

Moreover when I use my ip instead of localhost in the Url, this problem is not appeared.

最后一点,我不这么用ASP.NET和一般的网络和服务器端Web应用程序的经验。

Final note, I am not so experienced with ASP.NET and in general networking and server side web applications.

我使用Windows 8时,Visual Studio 2012,SQL Server 2012中,IIS前preSS

I am using windows 8, visual studio 2012, sql server 2012,IIS express

推荐答案

最后,我发现我的问题的解决方案。它与默认连接数据库(简单成员)的初始化做。

Eventually, I found the solution of my problem. It had to do with the initialization of the default-connection database (simple membership).

要更precise,我搬到这条线WebSecurity.InitializeDatabaseConnection(DefaultConnection,用户配置,用户ID,用户名,autoCreateTables:真);从过滤器 - > InitializeSimpleMembershipAttribute.cs,以便尽快Global.asax中初始化发生地

To be more precise, I moved this line "WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);" from Filters -> InitializeSimpleMembershipAttribute.cs to Global.asax in order the initialization to take place as soon as possible.

这篇关于System.Data.SqlClient.SqlException: - ASP.NET MVC 4 C#中使用默认SimpleMembership,错误Internet应用程序模板用户登录失败XXX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆