简体   繁体   English

如何显示用户列表和更改密码的选项?

[英]How do I display a list of users and an option to change their passwords?

I have a need to create a simple user administration page where I can simply show a list of users and change their passwords. 我需要创建一个简单的用户管理页面,在这里我可以简单地显示用户列表并更改其密码。 The application isn't very big so there are only a handful of users using the system but like any infrastructure they sometimes forget what their passwords are. 该应用程序不是很大,因此只有少数用户在使用该系统,但是像其他基础结构一样,他们有时会忘记密码。 I need a simple solution to do this. 我需要一个简单的解决方案来做到这一点。

I created an Admin controller 我创建了一个管理员控制器

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyProject.Models;
using MyProject.ViewModels;
using Microsoft.AspNet.Identity.EntityFramework;

namespace MyProject.Controllers
{
    public class AdminController : Controller
    {

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Users()
        {
           var context = new ApplicationDbContext(); 
           var allusers = context.Users;
           return View(allusers);
        }
    }
}

I need some help retuning this list to a view and also creating the crucial password reset part as well. 我需要一些帮助来将此列表重新调整为视图,以及创建关键的密码重置部分。 There seem to be quite a few different ways of doing this so I'm a bit confused as to how I can approach it. 似乎有很多不同的方法可以做到这一点,所以我对如何实现它有点困惑。

rly Admin can change passwords ? rly Admin可以更改密码吗?

here i found some code 在这里我找到了一些代码

maybe will help 也许会有所帮助

You are using default login and register from asp.net ? 您正在使用默认登录并从asp.net注册吗? Why u want to add useless functionality like admin changing passwords ? 为什么您要添加无用的功能,例如管理员更改密码? I will suggest to do more complex staff :) Use EntityFramework and generate user Table and when someone register add him to this table. 我建议做更多复杂的工作人员:)使用EntityFramework并生成用户表,当有人注册时将其添加到该表中。 Then when you are in Admin Panel get data from that table and display it. 然后,当您进入管理面板时,从该表中获取数据并显示它。 Because when user login they can manage own account( including password) 因为当用户登录时,他们可以管理自己的帐户(包括密码)

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

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