Since there is no implicit conversion between Mvc.JsonResult
and Mvc.ViewResult
I cannot just utilize a conditional operator but instead end up with a cast.
Which leads me to my question is the performance hit I will take for boxing the JsonResult worth it or should I just do a normal if...else
block?
The code below appears inside a normal controller action: public ActionResult Inactivate()
No Boxing
if (Request.IsAjaxRequest())
{
return Json(foo);
}
else
{
return View(bar);
}
VS Boxing
return Request.IsAjaxRequest() ? (ActionResult)Json(foo) : View(bar);