我遇到了一个问题,即用户管理器中的各种方法都不起作用。我尝试清除我的 Resharper 缓存,甚至完全关闭 resharper,但即使没有运行 resharper,错误消息也是相同的。它坚持认为这些方法不存在。它们在所有其他 MVC 项目中都能正常工作,除了我正在研究的那个。
当我将鼠标悬停在其中一种方法上时,它给了我基本的“缺少使用指令或程序集引用”。它没有给我一个导入选项,所有导入似乎都应该如此,但我的项目不会承认这些方法。
对如何解决此问题有任何线索吗?
代码为文本:
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using MEV3.Models.Helpers;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security;
using MEV3.Models;
如您所见,我所有的导入都是正确的。
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
{
if (ModelState.IsValid)
{
var user = await UserManager.FindByNameAsync(model.Email);
if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
{
// Don't reveal that the user does not exist or is not confirmed
return View("ForgotPasswordConfirmation");
}
var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
var callbackUrl = Url.Action("ResetPassword", "Account",
new { UserId = user.Id, code = code }, protocol: Request.Url.Scheme);
await UserManager.SendEmailAsync(user.Id, "Reset Password",
"Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>");
return View("ForgotPasswordConfirmation");
}
// If we got this far, something failed, redisplay form
return View(model);
}