public JsonResult GetFileText(string str) { string fileText = null, errorMessage = null; int id; try { if (int.TryParse(str, out id)) { fileText = ResourceUtility.GetFileTextForHtmlResource(id, out errorMessage); } else { if (!System.IO.File.Exists(str)) { errorMessage = string.Format("ERROR!! The file {0} does not exist!", str); } else { fileText = Utility.ReturnFileContents(str); } } } catch (Exception e) { errorMessage = string.Format("ERROR!! An Exception occured in method GetFileText! e.Message:\r\n{0}", e.Message); } if (errorMessage == null) { return(Json(fileText, JsonRequestBehavior.AllowGet)); } else { return(Json(errorMessage, JsonRequestBehavior.AllowGet)); } }