【发布时间】:2011-03-21 06:12:43
【问题描述】:
我有一个需要以下功能的场景:
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 和 调用操作。
【问题讨论】:
-
您使用的是什么服务器端架构?用它来标记它,你更有可能吸引可以帮助你的人。
标签: jquery asp.net-mvc-2 redirecttoaction jsonresult