London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
Hi Kristoffer
It looks like you miss some services registration. Have a look of Startup file used in Foundation project
public void ConfigureServices(IServiceCollection services)
{
services.AddCmsAspNetIdentity<SiteUser>();
services.AddMvc(o => o.Conventions.Add(new FeatureConvention()))
.AddRazorOptions(ro => ro.ViewLocationExpanders.Add(new FeatureViewLocationExpander()));
if (_webHostingEnvironment.IsDevelopment())
{
services.Configure<ClientResourceOptions>(uiOptions => uiOptions.Debug = true);
}
services.AddCms();
services.AddDisplay();
services.AddTinyMce();
services.AddFind();
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = "/util/Login";
options.ExpireTimeSpan = new TimeSpan(0, 20, 0);
options.SlidingExpiration = true;
});
services.TryAddEnumerable(Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton(typeof(IFirstRequestInitializer), typeof(ContentInstaller)));
services.AddDetection();
}
https://raw.githubusercontent.com/episerver/foundation-mvc-cms/net5/src/Foundation/Startup.cs
Thanks Vincent!
I actually had this Startup.cs as my guidance:
https://github.com/episerver/Foundation/blob/net5/src/Foundation/Startup.cs
And that is for Commerce as well so the AddCms() I think was the key here.
/Kristoffer
Hi!
I'm trying to upgrade a site from CMS 11 to 12 and the site compiles but wont startup.
public class Program { public static void Main(string[] args) { var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); var isDevelopment = environment == Environments.Development; if (isDevelopment) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Warning() .WriteTo.File("app_data/log.txt", rollingInterval: RollingInterval.Day) .CreateLogger(); } CreateHostBuilder(args, isDevelopment).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args, bool isDevelopment) { if (isDevelopment) { return Host.CreateDefaultBuilder(args) .ConfigureAppConfiguration(config => { config.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("COMPUTERNAME")}.json", optional: true, reloadOnChange: true); }) .ConfigureCmsDefaults() .UseSerilog() .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); } else { return Host.CreateDefaultBuilder(args) .ConfigureCmsDefaults() .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); } } }
public class Startup { private readonly IWebHostEnvironment _webHostingEnvironment; private readonly IConfiguration _configuration; public Startup(IConfiguration configuration, IWebHostEnvironment webHostEnvironment) { _configuration = configuration; _webHostingEnvironment = webHostEnvironment; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc() .AddRazorOptions(ro => ro.ViewLocationExpanders.Add(new FeatureViewLocationExpander())); if (_webHostingEnvironment.IsDevelopment()) { services.Configure<ClientResourceOptions>(uiOptions => { uiOptions.Debug = true; }); } services.AddEmbeddedLocalization<Startup>(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute(name: "Default", pattern: "{controller}/{action}/{id?}"); endpoints.MapControllers(); endpoints.MapContent(); }); } }
gives me:
I guess it could be the Core projects setup as well but I cannot figure this one out.
Thanks!
/Kristoffer