I found the inclusion of IStartupFilter in this section confusing as there did not seem to be a valuable use case. See my SO question https://stackoverflow.com/questions/51437607/what-is-the-point-of-istartupfilter-in-asp-net-core/52178476#52178476 . I think that it is better covered in the section "enhance an app from an external assembly in ASP.NET Core with IHostingStartup" or the doc should make it clear that external assemblies are the main use case.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hello @mikedamay ... Thanks for commenting.
IStartupFilter isn't required for IHostingStartup, nor can it be seen as a main use case in hosting startups. It just so happens that that the StartupDiagnostics example uses an IStartupFilter to activate a pair of middlewares that are used to provide some diagnostic info on requests ... it's just to show-and-tell for how something like that is done. IStartupFilter remains focused on library implementations. I don't think we want to make any changes in how it's covered, but let's ask @Tratcher what he thinks. I defer to his judgement. I'm just a silly green dinosaur around here. :smile:
Startup filters are definitely an augmentation to Startup rather than an integral piece of it. They pair well with IHostingStartup as a means of injection into Startup, but that's not the only use case.
The Startup fitlers section could the highligheted as an extensibility mechanic. E.g. "Extending Startup: Startup Filters". The only thing I'd change from the example is to add the filter via WebHostBuilder.ConfigureServices rather than Startup.ConfigureServices. That gives you a better idea of the separation that's possible.
Extending Startup: Startup Filters
Ok
add the filter via WebHostBuilder.ConfigureServices rather than Startup.ConfigureServices
The sample is based on the templates. It would break from our guidance for doc sample construction to do it.
What's wrong with adding sample code in Program.Main? It can still be derived from the templates.
In early discussions on showing/using the extension methods in samples (I'll need to dig for it), it was decided not to use/show them in the samples. IIRC, it was felt by management that since the templates produce the Startup class with the ConfigureServices and Configure methods that they wanted all of the samples to embrace one way and be opinionated and consistent about it. IIRC, they saw the ext methods (at the time anyway) as just a nice-to-have thing and not something they really wanted push with devs.
If you recall, my 😵 _Nutjob Pattern_:tm: 😵 embraced them, and so I was on the side of the debate arguing for their use at the time with virtually all of the samples.
There's a good chance that the discussion(s) took place over email. I don't have access to that account (it's closed down), so I won't be able to forward the message chain to you if that's where we discussed it.
I'll look and see if it was a GH discussion and get back to you.
I don't follow, the sample would still have a Startup class. I'm talking about adding the IStartupFilter as a host service to show how it augments Startup from the outside.
as a host service == WebHostBuilder.ConfigureServices
Just following orders ... I was told not to use that host builder extension method in samples.
No worries ... @Rick-Anderson You good on this?
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddTransient<IStartupFilter, RequestSetOptionsStartupFilter>();
}
.UseStartup<Startup>()
.Build();
[EDIT] That BuildWebHost needs an update, too. The sample app is 2.0.
I'll add a line or two that say something to the effect ...
adding the IStartupFilter as a host service to show how it augments Startup from the outside.
Approved :point_up: :+1:
I'll get this done PDQ.
@guardrex do what chris suggests always unless it's an editorial point.
Thank you very much for giving this your consideration. Extremely impressive.
The quality of the documentation gives these technologies a considerable edge over the competition.
On 5 Sep 2018, at 20:34, Rick Anderson notifications@github.com wrote:
@guardrex https://github.com/guardrex do what chris suggests always unless it's an editorial point.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/aspnet/Docs/issues/8407#issuecomment-418854426, or mute the thread https://github.com/notifications/unsubscribe-auth/AClzxrHPNKvstgCOKkQIgLzkG-nq8XI-ks5uYCdJgaJpZM4WaRJw.
Most helpful comment
Thank you very much for giving this your consideration. Extremely impressive.
The quality of the documentation gives these technologies a considerable edge over the competition.