- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用 VS2015 MVC Controller ,特别是 User.Identity 上的 GetUserID
我已经看到许多与此相关的类似问题,其中声明要添加对 Microsoft.AspNet.Identity 的引用,但是正如您所看到的那样,它已被引用。
我假设我丢失了一个包裹或一些我无法弄清楚的东西
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Mvc;
using Web_Test.Models;
namespace Web_Test.Controllers
{
public class TestController : Controller
{
public TestController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
{
UserManager = userManager;
SignInManager = signInManager;
}
public UserManager<ApplicationUser> UserManager { get; private set; }
public SignInManager<ApplicationUser> SignInManager { get; private set; }
public IActionResult Index()
{
//GetUserId() underlined in Red in VS2015
//IIDentity does not contain a definition for 'GetUserId'
string currentUserId = User.Identity.GetUserId();
return View();
}
}
}
最佳答案
添加以下内容对我有用。我还需要添加 NuGet 包 Microsoft ASP.NET Identity Core @Badri.提到
using Microsoft.AspNet.Identity; // NuGet: Microsoft ASP.NET Identity Core.
关于c# - IIDentity 不包含 'GetUserId' 的定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27390694/
我使用 token 来保护我的 Web API 网站,并从 AngularJS 客户端应用程序使用此 API。 这样我就可以使用基于 token 的身份验证进行登录。我的问题是我无法在 Web API
我正在使用 Twitter4j 从我关注的用户处获取推文。每次获取 1000 个,但我对如何在输出中包含用户 ID 和用户名有些困惑。 这是我用来获取推文的代码: try {
我正在使用 ASP.Net MVC 5 并且我在我的代码中调用了这一行 string userId = User.Identity.GetUserId(); ASP.NET MVC 是在每次调用时从表
我正在尝试使用 VS2015 MVC Controller ,特别是 User.Identity 上的 GetUserID 我已经看到许多与此相关的类似问题,其中声明要添加对 Microsoft.As
我定义了一个临时变量来获取当前用户 ID,它总是返回 null。 这是截图: 为什么? 更新: // // POST: /Account/Login [HttpPost]
我正在尝试对包含以下行的代码进行单元测试: UserLoginInfo userIdentity = UserManager.GetLogins(User.Identity.GetUserId()).
当我们有一个自定义的 IUserIdProvider 时,SignalR 框架何时调用 GetUserId 方法,如下所示: public class RealTimeNotificationsUse
问题 User.Identity.GetUserId()如何找到当前用户的Id? 它是从 Cookie 中找到用户 ID,还是查询数据库?还是其他方法? 问题 由于某种原因,当我将有效的 Bearer
任何人都可以帮助阐明 Live SDK (v5.6) 的实现与 Microsoft.AspNet.Identity.Owin.dll 中发生的事情吗? 通过以下方式验证成功后返回的用户id: //MV
当我使用 User.Identity.GetUserId() 方法时,它返回 null。我正在尝试制作一种方法(基于 MVC 的 AccountController)来更改用户的密码。问题在于 Use
我已经创建了一个自定义的 User 类来实现 IUser。当我注册一切正常时,表被创建(如果它们不存在)并且看起来一切正常,但是,正如主题所述,我无法让 User.GetUserId() 工作。它总是
用户可以伪造 User.Identity.GetUserId() 吗?或者假设它总是返回一个用户存在或 null 的 UserId 是否安全? 最佳答案 使用 ASP.Net Identity,这些详
我有一个带有 GAE 服务器的 Android 应用程序。我尝试按照 developers.google.com 上的描述对用户进行身份验证,我将用户参数添加到端点方法等。我得到一个不为 null 的
我收到以下错误:值不能为空。参数名称:principal 如何在 Controller 的构造函数中访问身份(userId)?我只能通过将失败的调用包装在函数中(两者都在下面突出显示)来使其工作。 需
我有 ChangePassword 方法,我有 User.Identity.GetUserId() 来查找 UserId。 Problem: It always return null. Don't
当我调用 UserManager.FindByIdAsync(User.Identity.GetUserId()) 时,它是缓存,还是在每次调用时调用数据库? 最佳答案 它不缓存,底层存储/dbcon
我正在使用 ASP.Net Identity 2,但很快希望在它变得更稳定时更改为 Identity 3(有人知道那可能是什么时候?)。这是我的代码示例: content.ModifiedBy = U
使用 Visual Studio 2013 Express MVC 应用程序并引用 MVC 5.2 Asp.Net.Identity.Core 2.0 在任何 Controller 内或我的应用程序中
我正在使用 asp.net 5 和 Entity Framework 7 创建 Web 应用程序,但我在让 User.Identity 工作时遇到了一些问题。在documentation ,它表示它位
我正在尝试创建一个用户模型,但我得到: 2018-12-18 09:47:07.567 [error]: uncaughtException: Cannot set property 'getUser
我是一名优秀的程序员,十分优秀!