protected internal JsonResult ClientSideViewError(string error, JsonRequestBehavior behavior)
 {
     ClientSideView jsonView = new ClientSideView();
     jsonView.Error = error;
     jsonView.Success = false;
     return new JsonResult() { Data = jsonView, JsonRequestBehavior = behavior };
 }
        protected internal JsonResult ClientSideView(string view, object model)
        {
            ClientSideView View = new ClientSideView();

            // Parse the view
            if (string.IsNullOrEmpty(view))
            {
                view = ControllerContext.RouteData.GetRequiredString("action");
            }

            ViewData.Model = model;

            string html = "";
            using (StringWriter sw = new StringWriter())
            {
                ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, view);
                ViewContext viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
                viewResult.View.Render(viewContext, sw);
                html = sw.GetStringBuilder().ToString();
            }

            View.Html = html;
            View.Model = model;
            View.Success = true;

            return new JsonResult() { Data = View, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }