I’m facing an problem, I have google and I didn’t find how to solve.
I have these two Action
public ActionResult ActionA(DTOA dtoA)
{
.....
}
[HttpPost]
public ActionResult ActionB(DTOB dtoB)
{
DTOA dto = new DTOA();
dto.ArraOfStringA = dtoB.ArraOfStringB;
dto.Id = dtoB.Id;
return RedirectToAction("ActionA", dto);
}
the models
public class DTOA
{
public int Id{get;set;}
public string[] ArraOfStringA { get; set; }
}
public class DTOB
{
public int Id{get;set;}
public string[] ArraOfStringB { get; set; }
}
so the situation is
When I post to ActionB, the array of string of dtoB parameter is populated with 2 itens. “1” and “2”
but when this action Redirect to ActionA, dtoA parameter is populated with 1 itens. “System.String[]”.
If I type in browser “domain/controler/ActionA?ArraOfStringA=1&ArraOfStringA=2”
the dtoA parameter is populated with two itens. “1” and “2” ( the expected behavior)
So, how can I redirect to ActionA passing an complex model with an property of array os string?
You might want to consider using
TempDatato store the model when transferring between two actions rather than using route parameters if the model is complex.