我正在使用 asp.net web api。我正在嘗試從服務(wù)器獲得肯定的響應(yīng),但是程序沒有看到控制器中的一種方法。它進(jìn)入控制器構(gòu)造函數(shù),但不會(huì)更進(jìn)一步?;貞?yīng)是狀態(tài)代碼 404,原因短語:未找到。我知道這可能是方法名稱/參數(shù)/其他方面的錯(cuò)字,但對(duì)我來說一切似乎都很好。我可能忽略了一些事情。API 工作正常,我用不同的方法嘗試過。這是控制器方法: [HttpGet] [Route("api/ClientFiles/GetScanStatus")] [ActionName("GetScanStatus")] private Tuple<bool, bool?, bool?> GetScanStatus(int scanTypeId, int clientId, int inventoryId) { //businessLogic here return new Tuple<bool, bool?, bool?>(false, null, null);調(diào)用控制器的方法: public static async Task<Tuple<bool, bool?, bool?>> GetScanStatus(int scanTypeId, int clientId, int inventoryId) { using (HttpClient client = new HttpClient()) { client.Timeout = new TimeSpan(0, 0, 90); HttpResponseMessage response = await client.GetAsync($"{ConnectionURL}api/ClientFiles/GetScanStatus/?scanTypeId={scanTypeId}&clientId={clientId}&inventoryId={inventoryId}").ConfigureAwait(false); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsAsync<Tuple<bool, bool?, bool?>>(); return result; } } return null; }response.RequestedUri曾是http://localhost:61372/api/ClientFiles/GetScanStatus/?scanTypeId=26&clientId=12&inventoryId=25482
1 回答

夢里花落0921
TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超6個(gè)贊
從您的代碼看來,您的控制器方法是private,因此不可見!
制作方法public
[HttpGet]
[Route("api/ClientFiles/GetScanStatus")]
[ActionName("GetScanStatus")]
public Tuple<bool, bool?, bool?> GetScanStatus(int scanTypeId, int clientId, int inventoryId) {
//...
}
我認(rèn)為它會(huì)起作用。
- 1 回答
- 0 關(guān)注
- 95 瀏覽
添加回答
舉報(bào)
0/150
提交
取消