问题描述
我正在尝试通过微服务实现Asp.net核心身份。我为身份创建了一个微服务。迁移身份并创建表。我创建了另一个项目来显示微服务的值。我成功获取并发布了微服务的值。但是将值发布到身份微服务时出现错误,显示未找到StatusCode 404。
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(User user)
{
HttpClient client = api.Initial();
var postTask = client.PostAsJsonAsync<User>("identity",user);
postTask.Wait();
var result = postTask.Result;
if (result.IsSuccessstatusCode)
{
return RedirectToAction("Index");
}
return View(user);
}
下面是身份API控制器的Post方法
[HttpPost]
public async Task<IActionResult> Post([FromBody] Userviewmodel user)
{
var idenUser = new MembershipUser();
idenUser.Email = user.Email;
idenUser.ChurchId = user.ChurchId;
idenUser.IsDeleted = false;
idenUser.PhoneNumber = user.MobileNo;
idenUser.UserName = user.LoginName;
var resultCreate = await userManager.CreateAsync(idenUser,user.Password);
if (resultCreate.Succeeded)
{
return StatusCode(StatusCodes.Status201Created,user);
}
else
{
return StatusCode(StatusCodes.Status404NotFound,user);
}
}
下面是身份API的ocelot.json API geteway代码
{
"DownstreamPathTemplate": "/api/IdentityAPI","DownstreamScheme": "http","DownstreamHostAndPorts": [
{
"Host": "localhost","Port": "57608"
}
],"UpstreamPathTemplate": "/identity","UpstreamHttpMethod": [ "GET","POST" ]
},{
"DownstreamPathTemplate": "/api/IdentityAPI/{id}","UpstreamPathTemplate": "/identity/{id}","PUT","DELETE" ]
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)