简体   繁体   中英

Asp.net mvc return to controller from jsonresult

[HttpPost]
public JsonResult DelayReminder(string reminderId)
{
ReminderStatus rs = new ReminderStatus();


rs.BaseProps.RequesterUserInfo.UserID = SessionManager.Current.CurrentUser.UserID;


ReminderServiceHelper.InsertNewStatus(Convert.ToInt32(reminderId), rs);

return Json(apptype, JsonRequestBehavior.AllowGet); // Problem...
}

Instead of return Json(apptype, JsonRequestBehavior.AllowGet); how can i write below ?

return RedirectToAction("GetLawDetail", "Law", new { _lawID = baseappid });

If anybody wants to see Javascript:

 $.ajax({
                    type: 'POST',
                    url: '/Reminders/DelayReminder/',
                    data: {
                        'apptype': '@ViewData["apptype"]',
                        'baseappid': '@ViewData["baseappid"]',
                        'reminderId': $("#reminderId").val(),
                        'ddlDelayDuration': $("#ddlDelayDuration").val()
                    },
                    dataType: 'json',
                    success: function (result) {

                        if (result != null) {
                    }

                            ....
                            ..

How can i return to Law controller to GetLawDetail actionresult inside of jsonresult ?

You can just return this action:

return GetLawDetail(baseappid)

You should also change the return type to Action result as pointed by @im1dermike.

Here's the complete code:

[HttpPost]
public ActionResult DelayReminder(string reminderId)
{
ReminderStatus rs = new ReminderStatus();


rs.BaseProps.RequesterUserInfo.UserID = SessionManager.Current.CurrentUser.UserID;


ReminderServiceHelper.InsertNewStatus(Convert.ToInt32(reminderId), rs);

return GetLawDetail(apptype); // Problem...
}

Although, it will return you the whole rendered page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM