How to pass parameters of a controller function with AjaxExtensions.ActionLink via request body?

  Kiến thức lập trình

I was using LinkExtensions.ActionLink (with HtmlHelper) to pass parameters to a function in a controller. It’s a significant amount of data that I convert to and from base64 using a model binder (an array of a custom non-primitive type). Normally, the parameters are routed through the URL query via a GET request, and I quickly hit the length limit of that (the base64 gets very long).

My idea was then to perhaps send this data over a POST request. I looked into Ajax.ActionLink, found that with AjaxOptions, the HttpMethod could be set to POST. I added an HttpPostAttribute to the controller function in question and also added [FromBody] to parameters of that function.

The created ActionLink via Ajax.ActionLink still continues to insert the parameters for the function to the query of the URL. How can I pass them via request body? Is it even possible with Ajax.ActionLink or do I need to find another option?

New contributor

TEK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.