I'm trying to join all inputs at an AJAX call to a single string var.
In the backend we have a public JsonResult() which is being called from the frontend with their arguments.
With Request.QueryString.AllKeys we get {string[0]} when it is an AJAX call. When it's a parameter in the URL it returns correctly.
Code we are using is similar to this:
public JsonResult CustomerEdit(Guid customer, int status, string newName, string newLocation, Guid warehouse)
{
...
var parts = new List<string>(); // using System.Collections.Generic
foreach (var key in Request.QueryString.AllKeys)
parts.Add(Request.QueryString[key]);
string result = string.Join(", ", parts);
}
Is there a way to make this work with AJAX call? Or maybe a similar way to achieve this?
UPDATE
AJAX request is similar to:
$.ajax({
url: '/ControllerName/CustomerEdit',
type: "POST",
contentType: "application/json",
data: JSON.stringify({
customer: customer,
status: status,
newName: newName,
newLocation: newLocation,
warehouse: warehouse
}),
success: function (response) {
},
error: function (response) {
}
});