到达 webapi 终点,但所有参数为空
webapi end point is reached, but all parameters are empty
我有以下终点:
[HttpGet("/{auditReviewId}/{actioneeId?}/{entries?}")]
public IEnumerable<AuditReviewActionDto> GetAuditReviewActions(int auditReviewId, int? actioneeId = null, int? entries = null)
我使用 HttpClient
按以下方式调用它
var client = LocalHttpClient.CreateClient("UarBase");
var response = client.GetAsync("api/AuditDashboard/GetAuditReviewActions?auditReviewId=" + logId + "&actioneeId=" + SelectedKey + "&entries=" + Limit).Result;
无论我将 LogId、SelectedKey 或 Limit 设置为什么,当我到达端点时它们总是空的。
通过使用 [HttpGet("/{auditReviewId}/{actioneeId?}/{entries?}")]
设置 HttpGet,您将输入指定为 route 参数,然后将它们作为 query 传递 个参数。
如果您想通过查询传递参数,请将它们从您的路由中移除(只需使用 [HttpGet]
或仅提供基本路由),然后用 [FromQuery]
属性指定它们来自查询参数。
我有以下终点:
[HttpGet("/{auditReviewId}/{actioneeId?}/{entries?}")]
public IEnumerable<AuditReviewActionDto> GetAuditReviewActions(int auditReviewId, int? actioneeId = null, int? entries = null)
我使用 HttpClient
按以下方式调用它var client = LocalHttpClient.CreateClient("UarBase");
var response = client.GetAsync("api/AuditDashboard/GetAuditReviewActions?auditReviewId=" + logId + "&actioneeId=" + SelectedKey + "&entries=" + Limit).Result;
无论我将 LogId、SelectedKey 或 Limit 设置为什么,当我到达端点时它们总是空的。
通过使用 [HttpGet("/{auditReviewId}/{actioneeId?}/{entries?}")]
设置 HttpGet,您将输入指定为 route 参数,然后将它们作为 query 传递 个参数。
如果您想通过查询传递参数,请将它们从您的路由中移除(只需使用 [HttpGet]
或仅提供基本路由),然后用 [FromQuery]
属性指定它们来自查询参数。