I have two very similar projects, before me first project was working fine, but other after my minor changing project lost correct working. I have understand that after my changing additionally I need to configure manually some options for AddRazorPages services.
Maybe this is not enough and there are other options changing after my changing.
At common I see a lot of various options in my project.
I want to print all of them for comparing and verification before and after my changing for understanding reason of lost correct working.
This is a list of option I see in my project.
209. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.AuthenticationOptions]
210. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.AuthenticationOptions]
211. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.AuthenticationOptions]
212. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.AuthenticationOptions]
213. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.AuthenticationOptions]
214. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
215. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
216. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
217. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
218. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.DataProtection.KeyManagement.KeyManagementOptions]
219. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Hosting.GenericWebHostServiceOptions]
220. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Hosting.GenericWebHostServiceOptions]
221. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Identity.IdentityOptions]
222. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Identity.IdentityOptions]
223. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Identity.IdentityOptions]
224. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Identity.IdentityOptions]
225. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Identity.IdentityOptions]
226. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions]
227. Singleton : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions]
239. Singleton : Microsoft.Extensions.Options.IOptions`1[TOptions]
249. Singleton : Microsoft.Extensions.Options.IOptionsMonitor`1[TOptions]
250. Singleton : Microsoft.Extensions.Options.IOptionsMonitorCache`1[TOptions]
251. Singleton : Microsoft.Extensions.Options.IPostConfigureOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
252. Singleton : Microsoft.Extensions.Options.IPostConfigureOptions`1[Microsoft.AspNetCore.HostFiltering.HostFilteringOptions]
253. Singleton : Microsoft.Extensions.Options.IValidateOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
254. Singleton : Microsoft.Extensions.Options.IValidateOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
255. Singleton : Microsoft.Extensions.Options.IValidateOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
256. Singleton : Microsoft.Extensions.Options.IValidateOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
257. Singleton : Microsoft.Extensions.Options.IValidateOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
258. Singleton : Microsoft.Extensions.Options.IValidateOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
259. Singleton : Microsoft.Extensions.Options.IValidateOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
260. Singleton : Microsoft.Extensions.Options.IValidateOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
323. Transient : Microsoft.EntityFrameworkCore.DbContextOptions
324. Transient : Microsoft.EntityFrameworkCore.DbContextOptions`1[BackendAPI.Model.ApplicationDbContext]
326. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Antiforgery.AntiforgeryOptions]
327. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions]
328. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Builder.ForwardedHeadersOptions]
329. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.DataProtection.DataProtectionOptions]
330. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Mvc.ApiBehaviorOptions]
331. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Mvc.MvcOptions]
332. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Mvc.MvcOptions]
333. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Mvc.MvcOptions]
334. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Mvc.MvcViewOptions]
335. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Mvc.MvcViewOptions]
336. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions]
337. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions]
338. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Mvc.RazorPages.RazorPagesOptions]
339. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Routing.RouteHandlerOptions]
340. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Routing.RouteOptions]
341. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Routing.RouteOptions]
342. Transient : Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions]
344. Transient : Microsoft.Extensions.Options.IPostConfigureOptions`1[Microsoft.AspNetCore.Mvc.MvcOptions]
345. Transient : Microsoft.Extensions.Options.IPostConfigureOptions`1[Microsoft.AspNetCore.Mvc.RazorPages.RazorPagesOptions]
How is possible to see/print all of this options?
CodePudding user response:
Try to get a list of configured option types by iterating the IServiceCollection
instance:
var configuredOptionTypes =
from descriptor in builder.Services
let serviceType = descriptor.ServiceType
where serviceType.IsGenericType
where serviceType.GetGenericTypeDefinition() == typeof(IConfigureNamedOptions<>)
let optionType = serviceType.GetGenericArguments()[0]
select optionType;
result: