public ActionResult Index()
        {
            //Remove query string
            Uri thisUri = new Uri(Request.Url.GetLeftPart(UriPartial.Path));

            // Check for content pages before returning a 404
            string title = thisUri.PathAndQuery;

            // remove beginning and ending slashes from uri
            if (title.StartsWith("/"))
            {
                title = title.Substring(1);
            }
            if (title.EndsWith("/"))
            {
                title = title.Substring(0, title.Length - 1);
            }

            var model = new ContentViewViewModel(title);

            if (model.ThePage != null)
            {
                return View(model.TheTemplate.ViewLocation, model);
            }
            else
            {
                HttpContext.Response.StatusCode = 404;
                return View("~/Views/Home/Error404.cshtml");
            }
        }
        public ActionResult PreviewContent(int id)
        {
            var model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailById(id) };
            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            if (model.ThePage != null)
            {
                ViewBag.IsPublished = model.IsPublished;
                return View(model.TheTemplate.ViewLocation, model);
            }

            model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailsByTitle("404") };

            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            ViewBag.IsPage = true;
            ViewBag.PageId = model.ThePage.ContentPageId;
            ViewBag.IsPublished = model.ThePage.IsActive;
            ViewBag.Title = model.ThePage.Title;
            ViewBag.Index = "noindex";
            ViewBag.Follow = "nofollow";

            HttpContext.Response.StatusCode = 404;
            Response.TrySkipIisCustomErrors = true;
            return View(model.TheTemplate.ViewLocation, model);
        }
Example #3
0
        public ActionResult PreviewContent(int id)
        {
            var model = new ContentViewViewModel { ThePage = ContentLoader.GetDetailById(id) };
            model.TheTemplate = ContentLoader.GetContentTemplate(model.ThePage.Template);
            model.PageData = ContentUtils.GetFormattedPageContentAndScripts(model.ThePage.HTMLContent);

            if (model.ThePage != null)
            {
                ViewBag.IsPublished = model.IsPublished;
                return View(model.TheTemplate.ViewLocation, model);
            }

            HttpContext.Response.StatusCode = 404;
            return View("~/Views/Home/Error404.cshtml");
        }
        public ActionResult PreviewContent(int id)
        {
            var model = new ContentViewViewModel(id);

            if (model.ThePage != null)
            {
                return View(model.TheTemplate.ViewLocation, model);
            }

            HttpContext.Response.StatusCode = 404;
            return View("~/Views/Home/Error404.cshtml");
        }