【问题标题】:how to check jsonresult output whether it is fail or success mvc如何检查 jsonresult 输出是失败还是成功 mvc
【发布时间】:2015-02-27 06:22:25
【问题描述】:

我在控制器中有下面给出的 JsonResult 方法..

    public async Task<JsonResult> Approve(string Decision, string Comments, string DeptCharged, string AcctCharged)
    {
        JSonOutPut jOut = new JSonOutPut();
         .......
         .......
         ......
        ........

         if (isApproved)
         {
                jOut.Status = "Success";
         }
         return Json(jOut);
    }

我在另一个方法中调用上述方法,即 ActionResult 在像这样的同一控制器中

public async Task<ActionResult> Mapprove(string Id)
{

  JsonResult jsonApprovals = await Approve( null, null, null, null);
  // here i need to check the status of jsonapprovals 
  //if it is success i need to do some data changes....
}

这里我需要检查 jsonApprovals 的状态是失败还是成功.. 如何检查 Jsonapprovals

的状态

【问题讨论】:

  • (JsonOutPut(jsonApprovals)).Status 没用?

标签: c# json asp.net-mvc asp.net-mvc-4 jsonresult


【解决方案1】:

你可以这样做:

JsonResult jsonApprovals = await Approve( null, null, null, null);
JSonOutPut resultset  = jsonApprovals.Data as JSonOutPut;
if(resultset !=null)
{
  // do here what you want
}

【讨论】:

    猜你喜欢
    • 2019-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多