Hi @ismcagdas,
I think this could be the problem - I didn't update that - how to do that / what needs to be done? Thanks in advance!
Thanks :)
"Azure AD, you can use OpenID Connect." -> is there any documentation somewhere ?
Thanks @sedulen :)
We have added this to hist project <myProjectname>.Web.Host.csproj
<Target Name="PrepublishScript" BeforeTargets="ComputeFilesToPublish"> <Exec Command="gulp build" /> <Exec Command="node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod --aot --outputHashing=all" />
Any other ideas?
Hi @sedulen that would be cool - thx in advance !
############################################################################
Complete startup:
############################################################################
public class Startup
{
private const string DefaultCorsPolicyName = "localhost";
private readonly IConfigurationRoot _appConfiguration;
private readonly IWebHostEnvironment _hostingEnvironment;
public Startup(IWebHostEnvironment env)
{
_hostingEnvironment = env;
_appConfiguration = env.GetAppConfiguration();
}
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add SAML SSO services.
services.AddSaml(_appConfiguration.GetSection("SAML"));
// In production, the Angular files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "wwwroot/dist";
});
//MVC
services.AddControllersWithViews(options =>
{
options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute());
}).AddNewtonsoftJson();
services.AddSignalR(options => { options.EnableDetailedErrors = true; });
//Configure CORS for angular2 UI
services.AddCors(options =>
{
var corsOrigin = _appConfiguration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray();
options.AddPolicy(DefaultCorsPolicyName, builder =>
{
//App:CorsOrigins in appsettings.json can contain more than one address with splitted by comma.
builder
.WithOrigins(
// App:CorsOrigins in appsettings.json can contain more than one address separated by comma.
corsOrigin
)
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
services.AddCors(options =>
{
options.AddPolicy("AllowAllOrigins", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
services.AddControllers();
var isAttendanceFeatureAvailable = bool.Parse(_appConfiguration["App:IsAccessControlFeatureAvailable"]);
IdentityRegistrar.Register(services);
AuthConfigurer.Configure(services, _appConfiguration);
if (isAttendanceFeatureAvailable)
{
services.AddSingleton<RabbitMQPersistentConnection>(sp =>
{
var logger = sp.GetRequiredService<ILogger<RabbitMQPersistentConnection>>();
var factory = new ConnectionFactory()
{
HostName = _appConfiguration["EventBusConnection"]
};
if (!string.IsNullOrEmpty(_appConfiguration["EventBusUserName"]))
{
factory.UserName = _appConfiguration["EventBusUserName"];
}
if (!string.IsNullOrEmpty(_appConfiguration["EventBusPassword"]))
{
factory.Password = _appConfiguration["EventBusPassword"];
}
if (!string.IsNullOrEmpty(_appConfiguration["EventBusPassword"]))
{
factory.Ssl.ServerName = _appConfiguration["EventBusConnection"];
}
if (!string.IsNullOrEmpty(_appConfiguration["EventBusPassword"]))
{
factory.Ssl.Enabled = true;
}
var url = _appConfiguration["NotificationUrl"];
return new RabbitMQPersistentConnection(factory, url);
});
}
//Identity server
if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"]))
{
IdentityServerRegistrar.Register(services, _appConfiguration, options =>
options.UserInteraction = new UserInteractionOptions()
{
LoginUrl = "/UI/Login",
LogoutUrl = "/UI/LogOut",
ErrorUrl = "/Error"
});
}
if (WebConsts.SwaggerUiEnabled)
{
//Swagger - Enable this line and the related lines in Configure method to enable swagger UI
services.AddSwaggerGen(options =>
{
options.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
options.SwaggerDoc("v1", new OpenApiInfo() { Title = "WFMOne API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.ParameterFilter<SwaggerEnumParameterFilter>();
options.SchemaFilter<SwaggerEnumSchemaFilter>();
options.OperationFilter<SwaggerOperationIdFilter>();
options.OperationFilter<SwaggerOperationFilter>();
options.CustomSchemaIds(type => type.FullName);
options.CustomDefaultSchemaIdSelector();
}).AddSwaggerGenNewtonsoftSupport();
}
//Recaptcha
services.AddRecaptcha(new RecaptchaOptions
{
SiteKey = _appConfiguration["Recaptcha:SiteKey"],
SecretKey = _appConfiguration["Recaptcha:SecretKey"]
});
if (WebConsts.HangfireDashboardEnabled)
{
//Hangfire(Enable to use Hangfire instead of default job manager)
services.AddHangfire(config =>
{
config.UseSqlServerStorage(_appConfiguration.GetConnectionString("Default"));
});
}
if (WebConsts.GraphQL.Enabled)
{
services.AddAndConfigureGraphQL();
}
if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksEnabled"]))
{
services.AddAbpZeroHealthCheck();
var healthCheckUISection = _appConfiguration.GetSection("HealthChecks")?.GetSection("HealthChecksUI");
if (bool.Parse(healthCheckUISection["HealthChecksUIEnabled"]))
{
services.Configure<HealthChecksUISettings>(settings =>
{
healthCheckUISection.Bind(settings, c => c.BindNonPublicProperties = true);
});
services.AddHealthChecksUI();
}
}
//Configure Abp and Dependency Injection
return services.AddAbp<WFMOneWebHostModule>(options =>
{
//Configure Log4Net logging
options.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseAbpLog4Net().WithConfig(_hostingEnvironment.IsDevelopment()
? "log4net.config"
: "log4net.Production.config")
);
options.PlugInSources.AddFolder(Path.Combine(_hostingEnvironment.WebRootPath, "Plugins"), SearchOption.AllDirectories);
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseStatusCodePagesWithRedirects("~/Error?statusCode={0}");
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
Bold.Licensing.BoldLicenseProvider.RegisterLicense("KbGuIWrFfeANDDqWuWDs5zYZuVLojmxIxYWupqW3Vg0=");
ReportConfig.DefaultSettings = new ReportSettings().RegisterExtensions(new List<string> { "BoldReports.Data.WebData" });
app.UseSpaStaticFiles();
//Initializes ABP framework.
app.UseAbp(options =>
{
options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization
});
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value)) { context.Request.Path = "/index.html"; await next(); }
});
app.UseStaticFiles();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName); //Enable CORS!
// app.UseCors("AllowAllOrigins");
app.UseAuthentication();
app.UseJwtTokenMiddleware();
var isAttendanceFeatureAvailable = bool.Parse(_appConfiguration["App:IsAccessControlFeatureAvailable"]);
if (isAttendanceFeatureAvailable)
app.UseRabbitListener();
if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"]))
{
app.UseJwtTokenMiddleware("IdentityBearer");
app.UseIdentityServer();
}
app.UseAuthorization();
using (var scope = app.ApplicationServices.CreateScope())
{
if (scope.ServiceProvider.GetService<DatabaseCheckHelper>().Exist(_appConfiguration["ConnectionStrings:Default"]))
{
app.UseAbpRequestLocalization();
}
}
//using (var scope = app.ApplicationServices.CreateScope())
//{
// if (scope.ServiceProvider.GetService<DatabaseCheckHelper>().IsPocDbExists(_appConfiguration["ConnectionStrings:POCDb"]))
// {
// app.UseAbpRequestLocalization();
// }
//}
if (WebConsts.HangfireDashboardEnabled)
{
//Hangfire dashboard &server(Enable to use Hangfire instead of default job manager)
app.UseHangfireDashboard(WebConsts.HangfireDashboardEndPoint, new DashboardOptions
{
Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_HangfireDashboard) }
});
app.UseHangfireServer();
}
if (bool.Parse(_appConfiguration["Payment:Stripe:IsActive"]))
{
StripeConfiguration.ApiKey = _appConfiguration["Payment:Stripe:SecretKey"];
}
if (WebConsts.GraphQL.Enabled)
{
app.UseGraphQL<MainSchema>();
if (WebConsts.GraphQL.PlaygroundEnabled)
{
app.UseGraphQLPlayground(
new GraphQLPlaygroundOptions()); //to explorer API navigate https://*DOMAIN*/ui/playground
}
}
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<AbpCommonHub>("/signalr");
endpoints.MapHub<ChatHub>("/signalr-chat");
endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksEnabled"]))
{
endpoints.MapHealthChecks("/health", new HealthCheckOptions()
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
}
});
if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksEnabled"]))
{
if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksUI:HealthChecksUIEnabled"]))
{
app.UseHealthChecksUI();
}
}
if (WebConsts.SwaggerUiEnabled)
{
// Enable middleware to serve generated Swagger as a JSON endpoint
app.UseSwagger();
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint(_appConfiguration["App:SwaggerEndPoint"], "WFMOne API V1");
options.IndexStream = () => Assembly.GetExecutingAssembly()
.GetManifestResourceStream("WFMOne.Web.wwwroot.swagger.ui.index.html");
options.InjectBaseUrl(_appConfiguration["App:ServerRootAddress"]);
}); //URL: /swagger
}
}
}
public static class ApplicationBuilderExtentions
{
public static RabbitMQPersistentConnection Listener { get; set; }
public static IApplicationBuilder UseRabbitListener(this IApplicationBuilder app)
{
Listener = app.ApplicationServices.GetService<RabbitMQPersistentConnection>();
var life = app.ApplicationServices.GetService<Microsoft.Extensions.Hosting.IApplicationLifetime>();
life.ApplicationStarted.Register(OnStarted);
//press Ctrl+C to reproduce if your app runs in Kestrel as a console app
life.ApplicationStopping.Register(OnStopping);
return app;
}
private static void OnStarted()
{
Listener.CreateConsumerChannel();
}
private static void OnStopping()
{
Listener.Disconnect();
}
}
Here is my Configure part - below the whole statup class
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseStatusCodePagesWithRedirects("~/Error?statusCode={0}");
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
Bold.Licensing.BoldLicenseProvider.RegisterLicense("KbGuIWrFfeANDDqWuWDs5zYZuVLojmxIxYWupqW3Vg0=");
ReportConfig.DefaultSettings = new ReportSettings().RegisterExtensions(new List<string> { "BoldReports.Data.WebData" });
app.UseSpaStaticFiles();
//Initializes ABP framework.
app.UseAbp(options =>
{
options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization
});
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value)) { context.Request.Path = "/index.html"; await next(); }
});
app.UseStaticFiles();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName); //Enable CORS!
// app.UseCors("AllowAllOrigins");
app.UseAuthentication();
app.UseJwtTokenMiddleware();
var isAttendanceFeatureAvailable = bool.Parse(_appConfiguration["App:IsAccessControlFeatureAvailable"]);
if (isAttendanceFeatureAvailable)
app.UseRabbitListener();
if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"]))
{
app.UseJwtTokenMiddleware("IdentityBearer");
app.UseIdentityServer();
}
app.UseAuthorization();
using (var scope = app.ApplicationServices.CreateScope())
{
if (scope.ServiceProvider.GetService<DatabaseCheckHelper>().Exist(_appConfiguration["ConnectionStrings:Default"]))
{
app.UseAbpRequestLocalization();
}
}
//using (var scope = app.ApplicationServices.CreateScope())
//{
// if (scope.ServiceProvider.GetService<DatabaseCheckHelper>().IsPocDbExists(_appConfiguration["ConnectionStrings:POCDb"]))
// {
// app.UseAbpRequestLocalization();
// }
//}
if (WebConsts.HangfireDashboardEnabled)
{
//Hangfire dashboard &server(Enable to use Hangfire instead of default job manager)
app.UseHangfireDashboard(WebConsts.HangfireDashboardEndPoint, new DashboardOptions
{
Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_HangfireDashboard) }
});
app.UseHangfireServer();
}
if (bool.Parse(_appConfiguration["Payment:Stripe:IsActive"]))
{
StripeConfiguration.ApiKey = _appConfiguration["Payment:Stripe:SecretKey"];
}
if (WebConsts.GraphQL.Enabled)
{
app.UseGraphQL<MainSchema>();
if (WebConsts.GraphQL.PlaygroundEnabled)
{
app.UseGraphQLPlayground(
new GraphQLPlaygroundOptions()); //to explorer API navigate https://*DOMAIN*/ui/playground
}
}
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<AbpCommonHub>("/signalr");
endpoints.MapHub<ChatHub>("/signalr-chat");
endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksEnabled"]))
{
endpoints.MapHealthChecks("/health", new HealthCheckOptions()
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
}
});
if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksEnabled"]))
{
if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksUI:HealthChecksUIEnabled"]))
{
app.UseHealthChecksUI();
}
}
if (WebConsts.SwaggerUiEnabled)
{
// Enable middleware to serve generated Swagger as a JSON endpoint
app.UseSwagger();
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint(_appConfiguration["App:SwaggerEndPoint"], "WFMOne API V1");
options.IndexStream = () => Assembly.GetExecutingAssembly()
.GetManifestResourceStream("WFMOne.Web.wwwroot.swagger.ui.index.html");
options.InjectBaseUrl(_appConfiguration["App:ServerRootAddress"]);
}); //URL: /swagger
}
}
}
ok here are more from log:
FATAL 2022-03-14 16:54:07,957 [1 ] Abp.AbpBootstrapper - System.ArgumentNullException: Value cannot be null. (Parameter 'value')
at System.Boolean.Parse(String value)
at WFMOne.Web.Startup.WFMOneWebHostModule.ConfigureExternalAuthProviders() in C:\TFSASPZERO2022\src\WFMOne.Web.Host\Startup\WFMOneWebHostModule.cs:line 148
at WFMOne.Web.Startup.WFMOneWebHostModule.PostInitialize() in C:\TFSASPZERO2022\src\WFMOne.Web.Host\Startup\WFMOneWebHostModule.cs:line 76
at Abp.Modules.AbpModuleManager.<>c.<StartModules>b__15_2(AbpModuleInfo module)
at System.Collections.Generic.List1.ForEach(Action
1 action)
at Abp.Modules.AbpModuleManager.StartModules()
at Abp.AbpBootstrapper.Initialize()
System.ArgumentNullException: Value cannot be null. (Parameter 'value')
at System.Boolean.Parse(String value)
at WFMOne.Web.Startup.WFMOneWebHostModule.ConfigureExternalAuthProviders() in C:\TFSASPZERO2022\src\WFMOne.Web.Host\Startup\WFMOneWebHostModule.cs:line 148
at WFMOne.Web.Startup.WFMOneWebHostModule.PostInitialize() in C:\TFSASPZERO2022\src\WFMOne.Web.Host\Startup\WFMOneWebHostModule.cs:line 76
at Abp.Modules.AbpModuleManager.<>c.<StartModules>b__15_2(AbpModuleInfo module)
at System.Collections.Generic.List1.ForEach(Action
1 action)
at Abp.Modules.AbpModuleManager.StartModules()
at Abp.AbpBootstrapper.Initialize()
FATAL 2022-03-14 16:54:07,982 [1 ] Microsoft.AspNetCore.Hosting.Diagnostics - Application startup exception
System.ArgumentNullException: Value cannot be null. (Parameter 'value')
at System.Boolean.Parse(String value)
at WFMOne.Web.Startup.WFMOneWebHostModule.ConfigureExternalAuthProviders() in C:\TFSASPZERO2022\src\WFMOne.Web.Host\Startup\WFMOneWebHostModule.cs:line 148
at WFMOne.Web.Startup.WFMOneWebHostModule.PostInitialize() in C:\TFSASPZERO2022\src\WFMOne.Web.Host\Startup\WFMOneWebHostModule.cs:line 76
at Abp.Modules.AbpModuleManager.<>c.<StartModules>b__15_2(AbpModuleInfo module)
at System.Collections.Generic.List1.ForEach(Action
1 action)
at Abp.Modules.AbpModuleManager.StartModules()
at Abp.AbpBootstrapper.Initialize()
at Abp.AspNetCore.AbpApplicationBuilderExtensions.InitializeAbp(IApplicationBuilder app)
at Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp(IApplicationBuilder app, Action1 optionsAction) at WFMOne.Web.Startup.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) in C:\TFSASPZERO2022\src\WFMOne.Web.Host\Startup\Startup.cs:line 290 at System.RuntimeMethodHandle.InvokeMethod(Object target, Span
1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
ERROR 2022-03-14 16:54:08,010 [orker] Microsoft.EntityFrameworkCore.Query - An exception occurred while iterating over the results of a query for context type 'WFMOne.EntityFrameworkCore.WFMOneDbContext'.
System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: 'WFMOneDbContext'.
at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed()
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at
Thanks - when do you expect to launch AspNet Zero v11.1?
Thanks @sedulen