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

Changing IHostingEnvironment.ApplicationName using ASPNETCORE_APPLICATIONNAME env variable #11085

Open
Chakrygin opened this issue Jun 11, 2019 · 3 comments
Labels
affected-few This issue impacts only small number of customers area-hosting Includes Hosting area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions enhancement This issue represents an ask for new feature or an enhancement to an existing one severity-minor This label is used by an internal tool
Milestone

Comments

@Chakrygin
Copy link

Currently it not possible to change IHostingEnvironment.ApplicationName property via environment variables.

Although the variable is correctly read in the WebHostBuilder class, it is overwritten in the UseStartup method.

https://github.com/aspnet/AspNetCore/blob/d24ec01224726fa85dc7683d0f70a94d9172bc94/src/Hosting/Hosting/src/WebHostBuilder.cs#L45
https://github.com/aspnet/AspNetCore/blob/d24ec01224726fa85dc7683d0f70a94d9172bc94/src/Hosting/Hosting/src/WebHostBuilderExtensions.cs#L75

Describe the solution you'd like

Maybe this fix in UseStartup method will solve the problem:

public static IWebHostBuilder UseStartup(this IWebHostBuilder hostBuilder, Type startupType)
{
    if (string.IsNullOrEmpty(hostBuilder.GetSetting(WebHostDefaults.ApplicationKey)))
    {
        var startupAssemblyName = startupType.GetTypeInfo().Assembly.GetName().Name;

        hostBuilder.UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName);
    }

    // ...
}
@analogrelay
Copy link
Contributor

Thoughts @davidfowl @Tratcher ? It does seem odd that the assembly name would clobber the environment variable since it makes the env-var useless.

@analogrelay analogrelay added this to the Backlog milestone Jun 11, 2019
@Tratcher
Copy link
Member

Why are you trying to change it? I'm told MVC stops working if you do. @rynowak

@davidfowl
Copy link
Member

We should have resolved this with the introduction of the new interface but we dropped the ball here. We need another property here, EntryPoint, see #7315

@Tratcher Tratcher added affected-few This issue impacts only small number of customers enhancement This issue represents an ask for new feature or an enhancement to an existing one severity-minor This label is used by an internal tool labels Nov 9, 2020 — with ASP.NET Core Issue Ranking
@amcasey amcasey added area-hosting Includes Hosting and removed feature-hosting labels 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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-few This issue impacts only small number of customers area-hosting Includes Hosting area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions enhancement This issue represents an ask for new feature or an enhancement to an existing one severity-minor This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests

6 participants