I have a scenario where I need the following functionality:
In View I have call as:
$.ajax({
type: "POST",
async: false,
dataType: 'json',
url: "ControllerA/ActionA",
data: { var1: some_value },
success: function (data) {
if (data == true) {
form.submit();
}
else if (data == false) {
}
});
// In ControllerA
public JsonResult ActionA(string var1)
{
/*
Some manipulation and calculations
*/
_slist = RedirectToAction("ActionC", "ControllerB", new { var1 = some_value});
string = _slist.First().ToString();
return RedirectToAction("ActionB", "ControllerB", new { var1 = var2 });
}
// In ControllerB
public JsonResult ActionB(string var1)
{
/*
Some manipulation and calculations
*/
return Json(false, JsonRequestBehavior.AllowGet);
}
public SelectList ActionC(string var1)
{
/*
Some manipulation and calculations
*/
Session["STRING"] = some_value;
return new SelectList(_storeOrderTimeDictionaryList, "Value", "Key");
}
I need JsonResult in the View Page, but the problems are as:
- As RedirectToAction returns redirecttorouteresult I can't directly return the JSonResut
- As I need the Session in ActionC I can't instantiate Controller and call the action.