Submitting a POST ajax call to a controller with an array parameter.
I have a parameter array,
I have a static array that a I use to check the parameter array against.
I have a third array created using the .Except method to create an array that is everything but the parameter values.
The POST ajax call works like it should. I can return and see the values I am sending to it. That's what I'm doing with that quick TempData. So, I know the parameter is not empty.
Here is the controller:
[HttpPost]
public ActionResult MyAction(string[] subLineNames)
{
//Static array to check against parameter
string[] sublineArray = new string[] { "BI/PD", "Hired", "Non-Owned", "PIP", "Addtl-PIP", "Medical Payments", "UM PD", "UM CSL", "UIM CSL", "Terrorism" };
//Create new array for all minus the values in the parameter
/* The error happens here. The .Trim is causing some issue I can't see. */
/* I know that jquery ajax call is sending a bunch of white space, so I use trim to get rid of the white space characters. */
string[] DifferArray = sublineArray.Except(subLineNames.Select(m => m.Trim())).ToArray();
//Test to ensure the array parameter is not empty. (it works and brings back what I sent to it)
if (subLineNames != null)
{
for (int i = 0; i < subLinesNames.Length - 1; i++)
{
TempData["AA"] += subLineNames[i];
}
}
}
Frustrating because I had this working prior. I didn't change anything that would cause it to now do this. Any help would be so appreciated.