you use the async handler for the desired http verb. it is called before the processing of the razor template.
public async Task OnGetAsync()
{
}
public async Task OnPostAsync()
{
}
note: this is all covered in the documentation.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi!
How to correctly make an asynchronous method call in the RazorPage model (with asynchronous database accesses) before its view is built?
The call from the constructor is not correct, because there is no access to either User or other global data.
And calling an asynchronous method (or asynchronous requests like wait var a = await _db.Table...) in the public void OnGet() method, it does not have time to be executed and Null errors appear in the RazorPage View.
I make synchronous requests in the public void OnGet() method, but I would like asynchronous ones.
How to do it?
Thanks!
you use the async handler for the desired http verb. it is called before the processing of the razor template.
public async Task OnGetAsync()
{
}
public async Task OnPostAsync()
{
}
note: this is all covered in the documentation.