Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot get data from response when using HttpClient.GetJsonAsync #1796

Closed
qwertylb opened this Issue Mar 14, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@qwertylb
Copy link

qwertylb commented Mar 14, 2019

When using HttpClient.GetJsonAsync, docList can't get Json data with Object List<Doc>. I set breakpoint in LogsController.cs, it's obvious that ActionResult already has Value. But docList is null. The following code snippet is a part of the webapplication.
How to get data and use it?
Thank you for your support...

QueryLogs.cshtml
<TextEdit Placeholder="PlayerGuid" bind-text="@account" />

<SimpleButton Clicked="@(async () => await GetLogs(account))" Class="form-control" Color="Color.Primary">
    Query
</SimpleButton>

<table>
    @if (docList == null)
    { <p>there are no doc to display</p>}
    else
    {
    @foreach (var doc in docList)
    {
        <tbody>
            <tr>
                <td>@doc.account</td>
                <td>@doc.money_after</td>
                <td>@doc.money_before</td>
                <td>@doc.operator_type</td>
                <td>@doc.item_info</td>
                <td>@doc.vipLevel</td>
                <td>@doc.quest_id</td>
                <td>@doc.weapon_id</td>
                <td>@doc.zone_id</td>
                <td>@doc.role_id</td>
            </tr>
        </tbody>}}

</table>


@functions{

    List<Doc> docList = new List<Doc>();
    string account;
    string document;

    public async Task GetLogs(string acc)
    {
        docList = await Http.GetJsonAsync<List<Doc>>("api/value/" + acc);
    }
}

LogsController.cs

private readonly ElasticClient _client;
public async Task<ActionResult<List<Doc>>> Search(string param)
{
    return  _client.Search<Doc>(s => s
        .From(0)
        .Size(10)
        .Query(q => q.Match(m => m.Field(f => f.account).Query(param)))).Documents.ToList<Doc>();     
}

@qwertylb qwertylb changed the title cannot get any data from response when using HttpClient.GetJsonAsync cannot get data from response when using HttpClient.GetJsonAsync Mar 15, 2019

@qwertylb qwertylb closed this Mar 15, 2019

@qwertylb

This comment has been minimized.

Copy link
Author

qwertylb commented Mar 15, 2019

it was post on AspNetCore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.