web api asp core : 纯文本文档的字符编码没有声明
web api asp core :The character encoding of the plain text document was not declared
我需要为 angular 6 创建 Web 服务。我在 asp 核心 2.1 中使用网络 api ...
当我创建此操作进行编辑时:
[HttpGet("{id}")]
[Route("GetRoleById")]
public async Task<Role> GetRoleById(int id)
{
return await _roleManag.FindByIdAsync(id);
}
它没有进入行动,它告诉我 Inspecter Element 中的错误:
The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature.
我在网络浏览器中输入 url:https://localhost:44390/api/role/GetRoleById/2
有什么问题吗?我如何解决这个问题?
您的路由过滤器有误:HttpGet
和 Route
具有相同的功能。只需将您的代码更改为:
[HttpGet("GetRoleById/{id}")]
public async Task<Role> GetRoleById(int id)
{
return await _roleManag.FindByIdAsync(id);
}
我需要为 angular 6 创建 Web 服务。我在 asp 核心 2.1 中使用网络 api ...
当我创建此操作进行编辑时:
[HttpGet("{id}")]
[Route("GetRoleById")]
public async Task<Role> GetRoleById(int id)
{
return await _roleManag.FindByIdAsync(id);
}
它没有进入行动,它告诉我 Inspecter Element 中的错误:
The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature.
我在网络浏览器中输入 url:https://localhost:44390/api/role/GetRoleById/2
有什么问题吗?我如何解决这个问题?
您的路由过滤器有误:HttpGet
和 Route
具有相同的功能。只需将您的代码更改为:
[HttpGet("GetRoleById/{id}")]
public async Task<Role> GetRoleById(int id)
{
return await _roleManag.FindByIdAsync(id);
}