title: how do i return json object in action result in mvc
body: <p>I have a method of action result in a controller where i have some conditions if the conditions fails then i want to send a json object to the view but i am not able to do it. can any one help me out.</p>
  
  <pre><code>        [HttpPost]
      public ActionResult Loginuser(LoginDetails newlogin)
      {
          LoginDetails objlogin = new LoginDetails();
          objlogin.UserEmail = newlogin.UserEmail;
          objlogin.UserPassword = newlogin.UserPassword;
          try
          {
              if (ModelState.IsValid)
              {
                  RegisterBAL Regball = new RegisterBAL();
                  objlogin = Regball.LoginUserBAL(objlogin);
                  if(objlogin.ResponseCode == "000")
                  {
                      if(objlogin.UserRole =="CityHelpdesk")
                      {
                          return RedirectToAction("CityHelpdesk", "RoleDashbord");
                      }
                      if (objlogin.UserRole == "CityAdmin")
                      {
                          return RedirectToAction("CityAdmin", "RoleDashbord");
                      }
                      if (objlogin.UserRole == "StateAdmin")
                      {
                          return RedirectToAction("StateAdmin", "RoleDashbord");
                      }
                      if (objlogin.UserRole == "StateHelpdesk")
                      {
                          return RedirectToAction("StateHelpdesk", "RoleDashbord");
                      }
  
                  }
                  else
                  {
                      return json object//// Hear i want to return the json object
                  }
              }
          }
          catch (Exception)
          {
              objlogin.ResponseCode = "EXC";
          }
  
      }
  </code></pre>