c# - 身份的注册方法在 IIS 上不起作用
问题描述
当我在本地运行我的应用程序时,我已经实现了 ASP.NET 身份管理及其工作正常。然后我将它部署到 IIS,现在身份中帐户控制器的“注册”方法向我抛出未经授权的响应。
我也更新了我的连接字符串。即使我从 Postman 访问了相同的 URL,我也得到了“200 OK”的结果。那就是用户被插入到“AspNetUsers”表中
请帮助是什么问题。部署应用程序是否出错。我刚刚部署了 5 次。
我的注册方法:-
// POST api/Account/Register
[AllowAnonymous]
[Route("Register")]
public HttpResponseMessage Register(RegisterBindingModel model)
{
HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
if (!ModelState.IsValid)
{
return Request.CreateResponse(HttpStatusCode.OK, modelError.CreateModelError(ModelState));
}
try
{
var user = new ApplicationUser() { UserName = model.UserName, Email = model.Email };
IdentityResult result = UserManager.Create(user, model.UserName);
if (!result.Succeeded)
{
httpResponseMessage.Content.Headers.Add("Identity_Insert", "Failed");
httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
}
}
catch (Exception ex)
{
employeeMaster.LogError<EmployeeMaster>(ex, Global.Class.Common.ErrorType.APIError, 0);
httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
}
return httpResponseMessage;
}
解决方案
推荐阅读
- json - 从 Java Swagger 模型创建 Json
- accessibility - 什么是正确的屏幕阅读器可访问标记
- java - 如何在加载/重新加载文件之前捕获 yml 解析器错误
- .net-core - 使用异步检索身份验证令牌以通过 HttpClientFactory 使用
- python - 如何在用户输入中使用 Django 过滤器的排除参数?
- html - 如何让页脚留在页面底部
- grep - 使用 grep 搜索具有特定条件的单词
- kotlin - 子类中的访问方法
- python - Tkinter 中的嵌入式 Matplotlib 图仅在按键事件上按下“g”时使用新数据更新。为什么?
- c# - 遍历作为列表的字典对象值