ASP.NET MVC 4 C# - Internet Application Template u

2019-08-21 09:01发布

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.

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).

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

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

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

1条回答
来,给爷笑一个
2楼-- · 2019-08-21 09:12

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

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.

查看更多
登录 后发表回答