我有一个需要以下功能的场景:
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");
}
我需要查看页面中的 JsonResult,但问题如下:
- 由于 RedirectToAction 返回 redirecttorouteresult 我不能直接返回 JSonResut
- 由于我需要 ActionC 中的 Session,我无法实例化 Controller 并调用该操作。