Reputation: 827
I have a controller like below
[HttpPost]
public JsonResult Index(string number)
{
....
ServiceReference1.WebsiteInterfaceSoapClient APITest = new ServiceReference1.WebsiteInterfaceSoapClient();
List<ServiceReference1.Student> ListStudents = APITest .CheckIDStudent("xxxxxxxxxxxxx", number).ToList();
....
}
and I have a method like this
[HttpPost]
public async Task<ActionResult> ValidateS(StudentsDetails userDetails, string marksPoint)
{
....
}
How can I pass all the data on ListStudents
like (ListStudents[0].ID, ListStudents[0].Name ...)
into ValidateS
method and show them on View
?
Upvotes: 0
Views: 57
Reputation: 347
You can't do the redirect function for [HttpPost]
action. So you have to change your ValidateS
action method to [HttpGet]
. and use TempData
feature.
[HttpPost]
public JsonResult Index(string number)
{
ServiceReference1.WebsiteInterfaceSoapClient APITest = new ServiceReference1.WebsiteInterfaceSoapClient();
List<ServiceReference1.Student> ListStudents = APITest .CheckIDStudent("xxxxxxxxxxxxx", number).ToList();
TempData["studentList"] = ListStudents;
}
[HttpGet]
public async Task<ActionResult> ValidateS(StudentsDetails userDetails, string marksPoint)
{
List<ServiceReference1.Student> studentList = TempData["studentList"] as List<ServiceReference1.Student>;
}
Upvotes: 2