简体   繁体   English

ASP.NET MVC从jsonresult返回到控制器

[英]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); 而不是返回Json(apptype,JsonRequestBehavior.AllowGet); how can i write below ? 我怎么在下面写?

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

If anybody wants to see Javascript: 如果有人想看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 ? 如何在jsonresult内部Law控制器返回到GetLawDetail actionresult

You can just return this action: 您可以返回以下操作:

return GetLawDetail(baseappid)

You should also change the return type to Action result as pointed by @im1dermike. 您还应按照@ 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. 虽然,它将返回您整个呈现的页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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