Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an overload for IWebHostBuilder.Configure that takes in AssemblyName #14183

Closed
fitdev opened this issue Sep 20, 2019 · 4 comments
Closed
Labels
area-hosting Includes Hosting area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Comments

@fitdev
Copy link

fitdev commented Sep 20, 2019

Is your feature request related to a problem? Please describe.

I am trying to create an internal library-based framework for authoring "hosted" apps, including ASP.NET apps. As such, I am not relying on the Startup class approach and instead I am following your guidelines for Startup-less configuration.

The problem comes if this configuration is split across several assemblies. In my case, there would be a "top-most" assembly with controllers and views, which would depend on other assemblies that are responsible for configuring ASP.NET. Turns out that routing does not work properly if IWebHostBuilder.Configure is called from other assembly (that does not contain controllers and actions).

Describe the solution you'd like

Ideally, it would be really nice if there was a mechanism to clearly provide all controller and action (and possibly other endpoint) "sources" as part of configuration process, perhaps as an overload of IWebHostBuilder.Configure accepting either a single AssemblyName as a string, or better yet an params? array of assembly names that should be looked in for relevant types (controllers, etc.).

@Tratcher Tratcher added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 20, 2019
@Tratcher
Copy link
Member

Turns out that routing does not work properly if IWebHostBuilder.Configure is called from other assembly (that does not contain controllers and actions). @rynowak this is because MVC/routing depends on AppName for discovering controllers, right? And AppName is set based on the caller of Configure.

@davidfowl
Copy link
Member

This has actually been broken since inception. Hosting tries to deduce the "application assembly" from the Startup class or the class that contains the Configure delegate, dupe of #7315.

We shouldn't be adding anything to hosting here, this is mainly about controller discovery and there are ways to explicitly add assemblies (https://docs.microsoft.com/en-us/aspnet/core/mvc/advanced/app-parts?view=aspnetcore-2.2).

Going forward we'll need to decide what our defaults are.

@mkArtakMSFT
Copy link
Member

mkArtakMSFT commented Sep 23, 2019

@davidfowl is there any other action pending here? Should this be cloased?

@davidfowl
Copy link
Member

Closed.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
@amcasey amcasey added the area-hosting Includes Hosting label Jun 1, 2023
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-hosting Includes Hosting area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests

6 participants