Skip to content

Commit

Permalink
Added a default controller to show how to set response caching header…
Browse files Browse the repository at this point in the history
…s for page rendering
  • Loading branch information
Jeavon committed Oct 27, 2022
1 parent 3122373 commit 4237b17
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Umbraco.Docs.Samples.Web/Controllers/DefaultController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Web.Common.Controllers;

namespace Umbraco.Docs.Samples.Web.Controllers
{
public class DefaultController : RenderController
{
public DefaultController(ILogger<RenderController> logger, ICompositeViewEngine compositeViewEngine, IUmbracoContextAccessor umbracoContextAccessor) : base(logger, compositeViewEngine, umbracoContextAccessor)
{
}

[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
public override IActionResult Index()
{
return CurrentTemplate(new ContentModel(CurrentPage));
}

}
}
5 changes: 5 additions & 0 deletions Umbraco.Docs.Samples.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public void ConfigureServices(IServiceCollection services)
.AddTutorials()
.Build();
#pragma warning restore IDE0022 // Use expression body for methods

services.Configure<UmbracoRenderingDefaultsOptions>(c =>
{
c.DefaultControllerType = typeof(DefaultController);
});
}

/// <summary>
Expand Down

0 comments on commit 4237b17

Please sign in to comment.