Option 1 :
public ActionResult Index()
{
string[] roles = new string[] { "Admin", "Supervisor", "Interviewer" };
var routeParameters = new RouteValueDictionary();
for (int i = 0; i < roles.Length; i++)
{
routeParameters["roles[" + i + "]"] = roles[i];
}
return RedirectToAction("Test", "Student", routeParameters);
}
public ActionResult Test(string[] roles)
{
return View("Index");
}
Output -

Option 2:
Use TempData
public ActionResult Index()
{
string[] roles = new string[] { "Admin", "Supervisor", "Interviewer" };
TempData["data"] = roles;
return RedirectToAction("Test", "Student");
}
public ActionResult Test()
{
string[] roles = (string[])TempData["data"];
return View("Index");
}
Output -

Option 3 :
Use Session
public ActionResult Index()
{
string[] roles = new string[] { "Admin", "Supervisor", "Interviewer" };
Session["data"] = roles;
return RedirectToAction("Test", "Student");
}
public ActionResult Test()
{
string[] roles = (string[])Session["data"];
return View("Index");
}
Output -
