Instead Type Casting to “object” or “object[]” or using RouteValueDictionary. A simple way to achieve the same is using “Newtonsoft.Json”
If using .Net Core 3.0 or later;
Default to using the built in System.Text.Json parser implementation.
@using System.Text.Json;
…….
@Url.Action("ActionName", "ControllerName", new {object = JsonConvert.SerializeObject(‘@ModalObject’) }))
If stuck using .Net Core 2.2 or earlier;
Default to using Newtonsoft JSON.Net as your first choice JSON Parser.
@using Newtonsoft.Json;
…..
@Url.Action("ActionName", "ControllerName", new {object = JsonConvert.SerializeObject(‘@ModalObject’) }))
you may need to install the package first.
PM> Install-Package Newtonsoft.Json
Then,
public ActionResult ActionName(string modalObjectJSON)
{
Modal modalObj = new Modal();
modalObj = JsonConvert.DeserializeObject<Modal>(modalObjectJSON);
}