[英]Get out the debug before entering the action in ASP.NET Core
I need to return Roles.Claims
in ASP.NET Core for dynamic permission. 我需要在ASP.NET Core中返回
Roles.Claims
以获得动态权限。
When I enter this url : https://localhost:44390/api/Role/GetRoleClaims/1008
当我输入此URL时:
https://localhost:44390/api/Role/GetRoleClaims/1008
this action will be executed: 该动作将被执行:
[HttpGet("GetRoleClaims/{id}")]
public Task<Role> GetRoleClaims(int? id)
{
return _roleManag.ClaimsOfRole(id.Value);
}
then execution goes to the service layer and runs this method: 然后执行转到服务层并运行此方法:
public Task<Role> FindRoleIncludeRoleClaimsAsync(int roleId)
{
return Roles.Include(x => x.Claims).FirstOrDefaultAsync(x => x.Id == roleId);
}
public async Task<Role> ClaimsOfRole(int id)
{
var role = await FindRoleIncludeRoleClaimsAsync(id);
return role;
}
The variable role
is filled with the correct data, but it does not get back to the action after this line return role;
变量
role
填充有正确的数据,但是在此行return role;
之后,它不会返回到操作return role;
It shows the web browser and shows this : 它显示了网络浏览器并显示了以下内容:
What is the problem? 问题是什么? How can I solve this problem?
我怎么解决这个问题?
Your ClaimsOfRole
is still an async
method and you are missing an await
here: 您的
ClaimsOfRole
仍然是一个async
方法,您await
这里错过了一个await
:
[HttpGet("GetRoleClaims/{id}")]
public async Task<Role> GetRoleClaims(int? id)
{
return await _roleManag.ClaimsOfRole(id.Value);
}
Your Secure Connection Failed error has nothing to do with that code. 您的“安全连接失败”错误与该代码无关。 It may be to do with:
可能与以下内容有关:
Options: 选项:
Either that, or you've just typed in the wrong port. 要么,要么您输入的端口错误。 Where did you get
44390
from? 您从哪里获得
44390
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.