Closed Deepa-Puranik closed 1 year ago
How does your configuration look in Startup?
StartUp file
var connectionString = this.Configuration.GetConnectionString("EPiServerDB");// Retrieve connection string here services.AddNotFoundHandler(o => { o.UseSqlServer(connectionString); o.BufferSize = 30; o.ThreshHold = 5; o.HandlerMode = FileNotFoundMode.On; o.IgnoredResourceExtensions = new[] { "jpg", "gif", "png", "css", "js", "ico", "swf", "woff" }; o.Logging = LoggerMode.On; o.LogWithHostname = false; }); services.AddOptimizelyNotFoundHandler(o => { o.AutomaticRedirectsEnabled = true; });
Configure() method:
app.UseEndpoints(endpoints => { endpoints.MapContent(); endpoints.MapRazorPages(); }); app.UseNotFoundHandler();
These should be the first ones in the Configure method: app.UseNotFoundHandler(); app.UseOptimizelyNotFoundHandler();
Updated like this in Alloy template : public void ConfigureServices(IServiceCollection services) { if (_webHostingEnvironment.IsDevelopment()) { AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(_webHostingEnvironment.ContentRootPath, "App_Data"));
services.Configure<SchedulerOptions>(options => options.Enabled = false);
}
var connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=" +
"|DataDirectory|\TestOptimizely.mdf; " +
"Integrated Security=True;MultipleActiveResultSets=True";// Retrieve connection string here
services.AddNotFoundHandler(o =>
{
o.UseSqlServer(connectionString);
o.BufferSize = 30;
o.ThreshHold = 5;
o.HandlerMode = FileNotFoundMode.On;
o.IgnoredResourceExtensions = new[] { "jpg", "gif", "png", "css", "js", "ico", "swf", "woff" };
o.Logging = LoggerMode.On;
o.LogWithHostname = false;
});
services.AddOptimizelyNotFoundHandler(o =>
{
o.AutomaticRedirectsEnabled = true;
});
services
.AddCmsAspNetIdentity
// Required by Wangkanai.Detection
services.AddDetection();
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromSeconds(10);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
services.AddForteEpiResponsivePicture();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseNotFoundHandler();
app.UseOptimizelyNotFoundHandler();
// Required by Wangkanai.Detection
app.UseDetection();
app.UseSession();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapContent();
endpoints.MapRazorPages();
});
app.UseForteEpiResponsivePicture();
}
Still not able to see NotFoundHandler menu in CMS.
Maybe it requires AddRazorPages in ConfigureServices
Added this line services.AddRazorPages(); in ConfigureServices. Still not able to see the handler.
Thank you, for your quick response on this. The issue got resolved.
After adding the necessary packages and configuration in StartUp file, not able to access the NotFoundHandler menu in CMS. CMS version installed is EPiServer.CMS(12.17.0) and packages installed are Geta.NotFoundHandler, Geta.NotFoundHandler.Admin and Geta.NotfoundHandler.Optimizely version 5.0.6. Added necessary configuration in appSettings.json and the custom error page is also not working. Please help if there is any missing configuration to make it work.