简体   繁体   English

ASP.NET MVC4 WebSecurity - 数据库存储位置

[英]ASP.NET MVC4 WebSecurity - DB Storage Location

I just installed MVC 4 and made a default internet project. 我刚刚安装了MVC 4并制作了一个默认的互联网项目。 I was able to create a username/login/change password. 我能够创建用户名/登录/更改密码。

In MVC 3, after creating a user, I would see an ASPNETDB.MDF file in the App_Data folder, and I would also be able to manage users/roles in the Website Administration Tool. 在MVC 3中,在创建用户之后,我会在App_Data文件夹中看到一个ASPNETDB.MDF文件,我也可以在网站管理工具中管理用户/角色。

with MVC 4, I do not see an ASPNETDB.MDF file, even if i click show all files. 使用MVC 4,即使我单击显示所有文件,我也看不到ASPNETDB.MDF文件。 Also, any new users created are not shown in the Website Administration Tool. 此外,创建的任何新用户都不会显示在网站管理工具中。

Is there anywhere else I can look to retrieve users / set rolls ? 有没有其他我可以寻找检索用户/设置卷?

Thanks 谢谢

I'm not sure whether you could use "Website Administration Tool" with MVC4 我不确定你是否可以使用MVC4的“网站管理工具”

Go to the Models folder and open AccountModeles.cs class. 转到Models文件夹并打开AccountModeles.cs类。

You will find the code, 你会找到代码,

public UsersContext()
            : base("DefaultConnection")
        {
        }  

Go to the web.config file See the connection string with the name DefaultConnection ,You can see the database where the User/Roles are stored in. 转到web.config文件查看名称为DefaultConnection的连接字符串,您可以看到存储用户/角色的数据库。

As far as I know, You have to Refresh your solution, Show All files and then look in the map App_Data. 据我所知,您必须刷新解决方案,显示所有文件,然后查看地图App_Data。 Perhaps you forgot to refresh? 也许你忘了刷新?

Also you can manually go to your .MDF file then drag it into Visual Studio. 您也可以手动转到.MDF文件,然后将其拖到Visual Studio中。 Then it will automatically open The server explorer where you can see the new users. 然后它将自动打开服务器资源管理器,您可以在其中看到新用户。

MVC 4 doesn't support the usage of Website Administration Tool as it uses WebMatrix's simple membership. MVC 4不支持使用网站管理工具,因为它使用WebMatrix的简单会员资格。

This is suggested in this article 这是在本文中提出的

The membership provider in MVC 4 Internet applications, referred to as SimpleMembership, does not use the database ASPNETDB.MDF. MVC 4 Internet应用程序中的成员资格提供程序(称为SimpleMembership)不使用数据库ASPNETDB.MDF。 You should find another database in the App_Data directory that is named using the convention aspnet-project name-999999999999.mdf, where "project name" is the name of the VS project it is created in and the number I believe uses date/time and maybe some other digits to make a somewhat unique id. 您应该在App_Data目录中找到另一个使用约定aspnet-project name-999999999999.mdf命名的数据库,其中“project name”是它创建的VS项目的名称,我认为它使用的是日期/时间和也许一些其他数字,使一个有点独特的ID。 You will find the user data in this database and it is not compatible with the website administration tool. 您将在此数据库中找到用户数据,但它与网站管理工具不兼容。 You can find out more about the SimpleMembership database and customizing it in this post . 您可以在本文中找到有关SimpleMembership数据库的更多信息并对其进行自定义

Open the web.config file in your solution to check where and by what name the mdf file is created. 打开解决方案中的web.config文件,以检查mdf文件的创建位置和名称。

You should be able find your db details over here in the config file: 您应该可以在配置文件中找到您的数据库详细信息:

</configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source= ******>

With that, you can open the respective database on SQL server, to check the details you were looking for 这样,您可以在SQL Server上打开相应的数据库,以检查您要查找的详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM