我正在尝试创建自己的自定义注册。哪个有效
但是当我尝试初始化dataContext时添加存储过程时,它将引发错误。这是我的代码
namespace Login.Controllers.Work
{
public class PostController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly DataContext _context;
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly IEmailSender _emailSender;
private readonly ILogger _logger;
public PostController(DataContext context, UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager, IEmailSender emailSender, ILogger<AccountsController> logger )
{
_userManager = userManager;
_signInManager = signInManager;
_emailSender = emailSender;
_logger = logger;
_context = context;
}
当我添加DataContext上下文并将其在下面设置为_context = context;我的Ajax查询出现错误500
错误消息是
HTTP500:服务器错误-服务器遇到意外状况,阻止其满足请求。 (XHR)POST-https://localhost:44345/SignUp
这是怎么了?
谢谢
答案 0 :(得分:0)
我忘记将服务注册添加到startup.cs文件中
为
services.AddDbContext<DataContext>(options => options.UseSqlServer(connection));
现在可以了 谢谢