I am supposed to create a functionality where the MVC.NET Core application submits the JSON request through a Web API within the public async Task OnPostAsync(Request request) method
public async Task<IActionResult> OnPostAsync(Request request)
{
if(request.OwnershipActivity == null || request.OwnershipActivity.Ownership == null)
{
ModelState.AddModelError("OwnershipAnswer", "You must select an option.");
}
if (!ModelState.IsValid)
{
return Page();
}
//Do POST to database then redirect to Index
//Submit JSON
creturn RedirectToPage("../Index");
}
How do I convert a current Model(Form) into a JSON?
Thank you for your help