public ActionResult ViewTester() { var views = GetViewFileNames(Request.PhysicalApplicationPath); var model = new DiagnosticViewTesterModel { RootFolder = BuildViewTree(views) }; return(View(model)); }
public ActionResult ViewTester(DiagnosticViewTesterModel model) { var json = string.Empty; if (!string.IsNullOrEmpty(model.Json)) { json = model.Json; } else if (model.JsonFile != null && model.JsonFile.ContentLength > 0) { var bytes = new byte[model.JsonFile.ContentLength]; model.JsonFile.InputStream.Read(bytes, 0, model.JsonFile.ContentLength); json = Encoding.UTF8.GetString(bytes); } if (string.IsNullOrEmpty(model.SelectedViewName)) { model.ErrorMessage = "No View selected"; return(View(model)); } var modelName = ParseViewForModelName(model.SelectedViewName, Request.PhysicalApplicationPath); var typ = StringToLoadedType(modelName); object mod; try { mod = typ == null || string.IsNullOrEmpty(json) ? null : JsonConvert.DeserializeObject(json, typ); } catch (Exception ex) { model.ErrorMessage = ex.Message; return(View(model)); } ViewBag.Title = string.Format("view tester - {0}", model.SelectedViewName); ForceViewLocation(ViewEngineCollection, model.SelectedViewName); return(View(model.SelectedViewName, mod)); }
public ActionResult ViewTester(DiagnosticViewTesterModel model) { var json = string.Empty; if (!string.IsNullOrEmpty(model.Json)) { json = model.Json; } else if (model.JsonFile != null && model.JsonFile.ContentLength > 0) { var bytes = new byte[model.JsonFile.ContentLength]; model.JsonFile.InputStream.Read(bytes, 0, model.JsonFile.ContentLength); json = Encoding.UTF8.GetString(bytes); } if (string.IsNullOrEmpty(model.SelectedViewName)) { model.ErrorMessage = "No View selected"; return View(model); } var modelName = ParseViewForModelName(model.SelectedViewName, Request.PhysicalApplicationPath); var typ = StringToLoadedType(modelName); object mod; try { mod = typ == null || string.IsNullOrEmpty(json) ? null : JsonConvert.DeserializeObject(json, typ); } catch (Exception ex) { model.ErrorMessage = ex.Message; return View(model); } ViewBag.Title = string.Format("view tester - {0}", model.SelectedViewName); ForceViewLocation(ViewEngineCollection, model.SelectedViewName); return View(model.SelectedViewName, mod); }
public ActionResult ViewTester() { var views = GetViewFileNames(Request.PhysicalApplicationPath); var model = new DiagnosticViewTesterModel { RootFolder = BuildViewTree(views) }; return View(model); }