Sending Json instead of Form Data in DynamicPermission
paradisehuman opened this issue · comments
سلام این کد اجرا میشه و مشکلی ندارم.
[HttpPost]
[Authorize(Policy = ConstantPolicies.DynamicPermission)]
[ActionName("Test")]
public ActionResult Test([FromForm] string model)
{
return Json("ok");
}
چطور میشه به جای ارسال فرم دیتا، جیسن ارسال کرد ؟
[HttpPost]
[Authorize(Policy = ConstantPolicies.DynamicPermission)]
[ActionName("Test")]
public ActionResult Test([FromBody] string model)
{
return Json("ok");
}
وقتی جیسن ارسال میکنم این ارور رو بهم میده :
An unhandled exception occurred while processing the request
InvalidOperationException: Incorrect Content-Type: application/json
Microsoft.AspNetCore.Http.Features.FormFeature.ReadForm()
Follow Index([FromBody]RoleViewModel model) and function postData().
Also don't use a simple string
here. Use a ViewModel
class.
More info about Model binding changes in ASP.NET Core
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.