模拟在ASP.NET中的成员资格用户成员、资格、用户、ASP

2023-09-03 12:58:39 作者:寂寞、绕指柔

在一个通用的 asp.net 的网站成员角色和散列的口令启用,我想提供模拟的管理者,使他们可以浏览网站,是的用户一样。该网站应该作为如果该用户登录,然后才能恢复到自己的登录。

什么是实现这一目标的最佳方法?

一个例子用例:有两种类型的用户的网站:买家和管理。 该网站提供了一个购买按钮购买由管理员给用户明确规定的东西。即只有买家可以使用购买按钮,进行付款。 用户有麻烦所以支持管理员可以'冒充'用户的登录和购买代其或看到他们所面临的困难。

如果没有模拟,唯一的办法就是让这code和否定看到用户的问题的目的。不,即使我没有使用散列密码,并使用 FormsAuthentication.SignOut()键,手动记录在管理员的用户。

我希望我上面的决策意识。

解决方案

看看这个样本中的codeproject.com。我认为它,你要寻找的。

In a generic asp.net website with Membership, Roles and hashed passwords enabled, I would like to provide the administrators with impersonation so that they may browse the website as that user would. The website should function as if that user is logged on and then be able to revert to their own login.

客户要求ASP.NET Core API返回特定格式,怎么办 续

What is the best approach to achieve this?

An example use-case: A website with two types of users: 'Buyer' and 'Admin'. The website provides a 'Purchase' button to buy something specifically provided to the user by the admins. i.e only that buyer can use the purchase button and make a payment. User has trouble so a support admin can 'impersonate' the user's login and purchase on their behalf or 'see' the trouble they are facing.

Without impersonation, the only way is to allow this in code and that negates the purpose of 'seeing the user's issue'. Not even if I was not using hashed passwords and had used FormsAuthentication.SignOut() and manually logged in the admin as the user.

I hope i am making sense above.

解决方案

Take a look at this sample on codeproject.com. I think it does what you're looking for.