因此,我复制了使用其文件制作的先前项目,并且我的asp身份框架给出了诸如Account Controller类和其他具有Email属性的错误,这是Microsoft身份用户身份。.我该如何解决此问题?
我尝试在两个文件夹之间复制所有内容,但是我不知道是否应该重做一些事情。
这是我的帐户控制器方法,其中电子邮件出现错误:
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using AEmployed.Models;
namespace AEmployed.Controllers
{
[Authorize]
public class AccountController : Controller
{
private ApplicationSignInManager _signInManager;
private ApplicationUserManager _userManager;
ApplicationDbContext context;
public AccountController()
{
context = new ApplicationDbContext();
}
public AccountController(ApplicationUserManager userManager,
ApplicationSignInManager signInManager)
{
UserManager = userManager;
SignInManager = signInManager;
}
public ApplicationSignInManager SignInManager
{
get
{
return _signInManager ?? HttpContext.GetOwinContext().Get<ApplicationSignInManager>();
}
private set
{
_signInManager = value;
}
}
public ApplicationUserManager UserManager
{
get
{
return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
}
private set
{
_userManager = value;
}
}
[AllowAnonymous]
public ActionResult Create()
{
ViewBag.Name = new SelectList(context.Roles.Where(u => !u.Name.Contains("Admin"))
.ToList(), "Name", "Name");
return View();
}
//
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Create(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.UserName, Email = model.Email };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link
// string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
// var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
// await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
//Assign Role to user Here
await this.UserManager.AddToRoleAsync(user.Id, model.UserRoles);
//Ends Here
return RedirectToAction("Index", "Users");
}
ViewBag.Name = new SelectList(context.Roles.Where(u => !u.Name.Contains("Admin"))
.ToList(), "Name", "Name");
AddErrors(result);
}
// If we got this far, something failed, redisplay form
return View(model);
}
这是我的packages.config类:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net471" />
<package id="bootstrap" version="3.4.1" targetFramework="net471" />
<package id="EntityFramework" version="6.2.0"
targetFramework="net471" />
<package id="jQuery" version="3.3.1" targetFramework="net471" />
<package id="jQuery.Validation" version="1.17.0"
targetFramework="net471" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.2"
targetFramework="net471" />
<package id="Microsoft.AspNet.Identity.EntityFramework"
version="2.2.2" targetFramework="net471" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.2"
targetFramework="net471" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7"
targetFramework="net471" />
<package id="Microsoft.AspNet.Razor" version="3.2.7"
targetFramework="net471" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3"
targetFramework="net471" />
<package id="Microsoft.AspNet.WebPages" version="3.2.7"
targetFramework="net471" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform"
version="2.0.0" targetFramework="net471" />
<package id="Microsoft.jQuery.Unobtrusive.Validation"
version="3.2.11" targetFramework="net471" />
<package id="Microsoft.Owin" version="4.0.0"
targetFramework="net471" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.0.0"
targetFramework="net471" />
<package id="Microsoft.Owin.Security" version="4.0.0"
targetFramework="net471" />
<package id="Microsoft.Owin.Security.Cookies" version="4.0.0"
targetFramework="net471" />
<package id="Microsoft.Owin.Security.Facebook" version="4.0.0"
targetFramework="net471" />
<package id="Microsoft.Owin.Security.Google" version="4.0.0"
targetFramework="net471" />
<package id="Microsoft.Owin.Security.MicrosoftAccount"
version="4.0.0" targetFramework="net471" />
<package id="Microsoft.Owin.Security.OAuth" version="4.0.0"
targetFramework="net471" />
<package id="Microsoft.Owin.Security.Twitter" version="4.0.0"
targetFramework="net471" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0"
targetFramework="net471" />
<package id="Modernizr" version="2.8.3" targetFramework="net471" />
<package id="Newtonsoft.Json" version="11.0.1"
targetFramework="net471" />
<package id="Owin" version="1.0" targetFramework="net471" />
<package id="WebGrease" version="1.6.0" targetFramework="net471" />
</packages>
Any help please??