【发布时间】:2019-03-20 14:10:33
【问题描述】:
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/Agent/GetPagedAgents?page={page}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "agent.api",
"Port": 80
}
],
"UpstreamPathTemplate": "/api/account/user/list/GetPagedAgents?page={page}",
"UpstreamHttpMethod": []
}]
我正在尝试将我的 UpstreamPathTemplate 从查询字符串重新路由到 DownstreamPathTemplate,
"http://accountmanagement/api/account/user/list/GetPagedAgents?page=1"
这是我发送到我的帐户管理服务的查询字符串,以便使用 ocelot 重新路由到我的代理服务。
这是我在代理服务中用于接收重新路由路径的控制器方法
[HttpGet]
[Route("GetPagedAgents")]
[ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
public IActionResult Get(string page, string pageSize, string filter,
string sortBy)
{
var Result = _agentServices.GetAll(Convert.ToInt32(page),
Convert.ToInt32(pageSize),filter,sortBy);
return Ok(Result);
}
但它不起作用。在我的 OUTPUT 窗口中显示消息:无法找到路径的下游路由:/api/account/user/list/GetPagedAgents,动词:GET
这意味着它把我的 UpstreamPath 作为
Upstream url path is /api/account/user/list/GetPagedAgents
这里缺少参数。
任何帮助将不胜感激。谢谢
【问题讨论】:
-
你确定这个网址
http://accountmanagement/api/account/user/list/GetPagedAgents?page=1可以达到你的行动吗?
标签: c# asp.net-mvc asp.net-core ocelot