试图访问ASPNETDB.MDF数据库文件以获取用户信息.ASP.NET MVC

编程入门 行业动态 更新时间:2024-10-27 15:24:13
本文介绍了试图访问ASPNETDB.MDF数据库文件以获取用户信息.ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好...我正在尝试访问ASPNETDB.MDF文件中包含的用户信息.我正在使用ASP.NET MVC.从Visual Studio启动ASP.NET配置工具时,将创建此文件.因此,我通过此ASP.NET配置工具创建了用户,角色等,并将数据保存到此数据库文件中.

Hey everyone... I'm trying to access user information that's contained within the ASPNETDB.MDF file. I'm using ASP.NET MVC. This file gets created when you launch the ASP.NET Configuration tool from Visual Studio. So, I create users, roles, etc. via this ASP.NET Configuration tool, and the data gets saved to this database file.

我需要访问要在我的应用程序中使用的用户信息(仅是用户名).例如,我想要做的是用用户名列表填充一个下拉列表(用户名是通过ASP.NET配置工具创建的,因此位于此ASPNETDB数据库文件中).我认为,如果我能弄清楚如何获得这些信息,那么我就可以弄清楚其余的信息.

I'm needing to gain access to user information (just the user name) to use within my application. For example, what I'm trying to do is populate a drop down list with a list of user names (which were created from the ASP.NET Configuration tool, and therefore reside within this ASPNETDB database file). I think if I can figure out how to get that information then I can figure out the rest.

有人会建议我做其他事情吗?我可以在主数据库中创建一个单独的用户表,但是我宁愿使用已经创建的ASPNETDB数据库中的一个用户表,只是我只使用一个源来提供用户信息,而不是两个.

Is there any other way someone would suggest me going about this? I could create a separate users table in my main database, but I would rather use the one in the ASPNETDB database that's already created, just so I use one source for my user's information and not two.

推荐答案

您可以使用 Membership.GetUser() 方法以 MembershipUser . 您还可以使用以下LINQ查询来获取用户名列表

You can use Membership.GetUser() method to get all users in the database as a MembershipUser. You can also use following LINQ Query to get a list of user names

var users = from user in Membership.GetUsers() orderby user.UserName select user.UserName

更多推荐

试图访问ASPNETDB.MDF数据库文件以获取用户信息.ASP.NET MVC

本文发布于:2023-11-12 16:48:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582016.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户信息   数据库文件   MDF   ASPNETDB   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!