在MVC会员应用程序中获取.aspx中的角色

时间:2013-08-31 19:11:53

标签: asp.net-mvc asp.net-membership

我使用的是使用mvc成员资格而不是rolemanager编写的应用程序,但我正在添加一个aspx页面,并希望使用mvc app附带的现有成员资格。如何在aspx页面中获取角色列表?和所有用户的列表?提前谢谢。

在rolemanger aspx场景中,我会使用:Membership.GetAllUsers()和Roles.GetAllRoles(),但它不能与mvc一起使用。我需要这个与aspx一起工作

Imports Nop.Core.Infrastructure
Imports Nop.Services.Helpers
Imports Nop.Core.Domain.Customers
Imports Nop.Services.Customers
Imports Nop.Core

ListBox1.DataSource = EngineContext.Current.Resolve(Of IWorkContext)().CurrentCustomer.CustomerRoles()
ListBox1.DataBind()

'this is the listbox on aspx page
<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>

如果每个角色的每个用户有多个角色,则重复列表框输出:

System.Data.Entity.DynamicProxies.CustomerRole_6E0DFC682B2D3247B3BEEED3063345A95D5742CE33B2761C4CB20A8C0A0AD639

0 个答案:

没有答案