November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
The call from Main in program.cs is a delegate to the ConfigureServices
so that call must match. Simplest way to fix this is to remove IConfiguration
from that parameter and inject it in the startup constructor instead.
e.g.
public class Startup
{
private readonly IConfiguration Configuration;
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
...
services.AddCmsCloudPlatformSupport(Configuration);
}
}
Now I get a different error. The CMS was loading before I applied the changes. This is just the base empty Optimizely site.
So unlike my first suspicion, this is probably caused by AddCmsCloudPlatformSupport since you try to run it in your dev environment?
if (!_webHostingEnvironment.IsDevelopment())
{
services.AddCmsCloudPlatformSupport(Configuration);
}
Ensure IWebHostEnvironment is injected in the constructor
The AddCmsCloudPlatformSupport only adds cloud related stuff. You can probably use it locally as well as long as all your services are configured locally.
A complete startup.cs example
public class Startup
{
private readonly IWebHostEnvironment _webHostingEnvironment;
private readonly IConfiguration Configuration;
public Startup(IWebHostEnvironment webHostingEnvironment, IConfiguration configuration)
{
_webHostingEnvironment = webHostingEnvironment;
Configuration = configuration;
}
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);
}
services
.AddCmsAspNetIdentity<ApplicationUser>()
.AddCommerce()
.AddAdminUserRegistration()
.AddEmbeddedLocalization<Startup>();
if (!_webHostingEnvironment.IsDevelopment())
{
services.AddCmsCloudPlatformSupport(Configuration);
}
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseAnonymousId();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapContent();
});
}
}
I am still getting the same error - same line. My connectionstring is in appsettings.Development.json. It's just the initial install. Yes, I am trying to run the project locally.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"EPiServer": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ConnectionStrings": {
"EPiServerDB": "Data Source=(LocalDb)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\dxp-cloud-test.mdf;Initial Catalog=dxp-cloud-test;Integrated Security=True;Connect Timeout=30"
},
"EPiServer": {
"Cms": {
"MappedRoles": {
"Items": {
"CmsEditors": {
"MappedRoles": [ "WebEditors", "WebAdmins" ]
},
"CmsAdmins": {
"MappedRoles": [ "WebAdmins" ]
}
}
}
}
}
}
This is my current Startup.cs
public class Startup
{
private readonly IWebHostEnvironment _webHostingEnvironment;
private readonly IConfiguration Configuration;
public Startup(IWebHostEnvironment webHostingEnvironment, IConfiguration configuration)
{
_webHostingEnvironment = webHostingEnvironment;
Configuration = configuration;
}
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);
}
services
.AddCmsAspNetIdentity<ApplicationUser>()
.AddCms()
.AddAdminUserRegistration()
.AddEmbeddedLocalization<Startup>();
if (_webHostingEnvironment.IsDevelopment())
{
services.AddCmsCloudPlatformSupport(Configuration);
}
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapContent();
});
}
}
Okay now it works thanks... looks like those instructions need to be updated.
Not too familiar with webHostingEnvironment parameters, is that line going to be an issue when I try and push to Integration environment?
if (!_webHostingEnvironment.IsDevelopment())
{
services.AddCmsCloudPlatformSupport(Configuration);
}
So I am working through the example here.
https://docs.developers.optimizely.com/digital-experience-platform/v1.2.0-dxp-cloud-services/docs/creating-a-new-cms-site-and-deploying
Seems simple enough. I'm in Step 1... item 4.
ConfigureServices
method in startup.cs file.After I do this, I can no longer run the project. I get this error.
'']
Not sure how to resolve?