我应该创建一个功能,其中 MVC.NET Core 应用程序通过公共异步任务 OnPostAsync(Request request) 方法中的 Web API 提交 JSON 请求
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");
}
如何将当前模型(表单)转换为 JSON?
感谢您的帮助