ASP.NET Core StatusCodePages driven by the Xperience Content Tree.
- Install the
Administration
package into the CMSApp project
Install-Package BizStream.Kentico.Xperience.Administration.StatusCodePages
- Install the
AspNetCore
package into the Xperience ASP.NET Core Mvc project:
dotnet add package BizStream.Kentico.Xperience.AspNetCore.StatusCodePages
OR
<PackageReference Include="BizStream.Kentico.Xperience.AspNetCore.StatusCodePages" Version="x.x.x" />
- Configure services in the
Startup.cs
of the Xperience Mvc project:
using BizStream.Kentico.Xperience.AspNetCore.StatusCodePages;
using Microsoft.Extensions.DependencyInjection;
// ...
public void ConfigureServices( IServiceCollection services )
{
services.AddControllersWithViews();
// ...
services.AddXperienceStatusCodePages();
}
public void Configure( IApplicationBuilder app, IWebHostEnvironment environment )
{
if( environment.IsDevelopment() )
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseXperienceStatusCodePages();
app.UseHsts();
}
// ...
}
- Register the Page Route in the Xperience Mvc App:
We recommend creating a
RegisterPageRoutes.cs
file in the root of the Xperience Mvc project for usage of theRegisterPageRouteAttribute
s.
using BizStream.Kentico.Xperience.AspNetCore.StatusCodePages;
using Kentico.Content.Web.Mvc.Routing;
// For "out-of-the-box" functionality
[assembly: RegisterStatusCodePageRoute]
// OR
// To use a custom Controller
[assembly: RegisterPageRoute( StatusCodeNode.CLASS_NAME, typeof( MyStatusCodeController ) )]