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

Web root is incorrect when using new minimal hosting API (WebApplication.CreateBuilder) #32415

Closed
DamianEdwards opened this issue May 5, 2021 · 2 comments · Fixed by #32604
Closed
Assignees
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed feature-minimal-hosting ✔️ Resolution: Fixed The bug or enhancement requested in this issue has been checked-in!
Milestone

Comments

@DamianEdwards
Copy link
Member

DamianEdwards commented May 5, 2021

When using the new minimal hosting API (e.g. WebApplication.CreateBuilder) the web root folder is incorrectly set resulting in static files not working.

Issue seems to be here somewhere as it looks like it's trying to combine a path that's already been combined in the constructor:

WebRootFileProvider = new PhysicalFileProvider(Path.Combine(ContentRootPath, WebRootPath));

@halter73 @davidfowl

Found in version 6.0.100-preview.5.21254.10

@DamianEdwards DamianEdwards added bug This issue describes a behavior which is not expected - a bug. area-runtime labels May 5, 2021
@DamianEdwards
Copy link
Member Author

DamianEdwards commented May 5, 2021

Workaround:

var builder = WebApplication.CreateBuilder(args);

// BUG: Workaround for https://github.com/dotnet/aspnetcore/issues/32415
builder.Environment.WebRootPath = System.IO.Path.Combine(builder.Environment.ContentRootPath, "wwwroot");
var fixedWebRootFileProvider = new PhysicalFileProvider(builder.Environment.WebRootPath);
switch (builder.Environment.WebRootFileProvider)
{
    case PhysicalFileProvider _:
        builder.Environment.WebRootFileProvider = fixedWebRootFileProvider;
        break;
    case CompositeFileProvider cfp when cfp.FileProviders is IFileProvider[] providers:
        providers[0] = fixedWebRootFileProvider;
        break;
}

@ghost
Copy link

ghost commented May 5, 2021

Thanks for contacting us.

We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@pranavkm pranavkm modified the milestones: 6.0-preview4, 6.0-preview5 May 13, 2021
@ghost ghost added Done This issue has been fixed and removed Working labels May 13, 2021
@DamianEdwards DamianEdwards added the ✔️ Resolution: Fixed The bug or enhancement requested in this issue has been checked-in! label May 28, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 27, 2021
@amcasey amcasey added area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-runtime labels Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed feature-minimal-hosting ✔️ Resolution: Fixed The bug or enhancement requested in this issue has been checked-in!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants