在index.cshtml @functions中,我能够从数据库检索数据,同时发送参数selectedDate,如下所示:
trackList =等待Http.GetJsonAsync>(“ / api / Lopstat / Tracks /” + selectedDate.ToString(“ yyyy-MM-dd”));
如果我想随请求发送两个参数怎么办?这可能吗?
答案 0 :(得分:0)
如果要发送两个参数,则可以为这些参数定义一个带有两个字段的类。此类将自动进行JSON编码并以字符串形式发送
您可以使用其签名显示在下面的SendJsonAsync方法:
public static async Task<T> SendJsonAsync<T>(this HttpClient httpClient, HttpMethod method, string requestUri, object content)
// And this is how you can use it in your code...
trackList = await Http.SendJsonAsync<Change this to the return type>( HttpMethod.Get, "/api/Lopstat/Tracks", MyObject);