Umbraco cloud project (v12). Created page types without template and used custom RenderController to pass same view for each page type. Pages are rendered but if that page is created without template it automatically returns 404 status. How could I prevent that?
UPDATE: Found out that, if page was created when template was not assigned to it will always return 404 status unless you assign any template to document type and repulish the content. This is done
in "HandlePublishedContent" method as pages created under those conditions weren't considered published content.
Custom Controller:
public class PageRenderController : RenderController
{
public PageRenderController(ILogger<RenderController> logger, ICompositeViewEngine compositeViewEngine, IUmbracoContextAccessor umbracoContextAccessor)
: base(logger, compositeViewEngine, umbracoContextAccessor)
{
}
public override IActionResult Index()
{
return View("/Views/_PageContent.cshtml", CurrentPage);
}
}
View Content:
@{
Layout = "_Layout.cshtml";
var pageContent = Model.HasProperty("contentList") ? Model.GetProperty("contentList") : null;
if (pageContent == null) return;
var items = pageContent.GetValue();
}
<partial name="~/Views/Partials/blocklist/default.cshtml" model="items" />
Custom controller and document type without template returns 404 status while rendering correctly
Umbraco cloud project (v12). Created page types without template and used custom RenderController to pass same view for each page type. Pages are rendered but if that page is created without template it automatically returns 404 status. How could I prevent that?
UPDATE: Found out that, if page was created when template was not assigned to it will always return 404 status unless you assign any template to document type and repulish the content. This is done in "HandlePublishedContent" method as pages created under those conditions weren't considered published content.
Custom Controller:
View Content:
is working on a reply...