dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.17k stars 9.93k forks source link

[NETSDKE2E]Warning "Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[16] The WebRootPath was not found: C:\Users\xxx\web\razorcli\wwwroot. Static files may be unavailable." displays after running razor.dll file in CLI. #53432

Closed vdanche closed 7 months ago

vdanche commented 7 months ago

Is there an existing issue for this?

Describe the bug

1.warning "Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[16] The WebRootPath was not found: C:\Users\xxx\web\razorcli\wwwroot. Static files may be unavailable." displayed after running razor.dll file in CLI. image

  1. Click http://localhost:5000, the page cannot be displayed well image

Expected Behavior

There is no any errors and warning after running *dll file. and the page( http://localhost:5000) can display well

Steps To Reproduce

Build: dotnet-sdk-8.0.200-preview.24064.2-win-x64 from https://github.com/dotnet/installer on windows11

1.mkdir web

  1. cd web 3.dotnet new sln -o razorcli 4.cd razorcli 5.dotnet new razor -o razortest 6.dotnet sln add razortest\razortest.csproj 7.dotnet build 8.dotnet C:\Users\v-danche\web\razorcli\razortest\bin\Debug\net8.0\razortest.dll 9.open the link http://localhost:500

Exceptions (if any)

8.warning "Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[16] The WebRootPath was not found: C:\Users\xxx\web\razorcli\wwwroot. Static files may be unavailable." displayed after running razor.dll file in CLI. image

9.The page cannot display well. image

C:\Users\v-danche\web\razorcli>dotnet C:\Users\v-danche\web\razorcli\razortest\bin\Debug\net8.0\razortest.dll info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[63] User profile is available. Using 'C:\Users\v-danche\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest. warn: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[16] The WebRootPath was not found: C:\Users\v-danche\web\razorcli\wwwroot. Static files may be unavailable. info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5000 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: C:\Users\v-danche\web\razorcli info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 GET http://localhost:5000/ - - - warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3] Failed to determine the https port for redirect. info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint '/Index' info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[103] Route matched with {page = "/Index"}. Executing page /Index info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[105] Executing handler method razortest.Pages.IndexModel.OnGet - ModelState is Valid info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[108] Executed handler method OnGet, returned result . info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[107] Executing an implicit handler method - ModelState is Valid info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[109] Executed an implicit handler method, returned result Microsoft.AspNetCore.Mvc.RazorPages.PageResult. info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[104] Executed page /Index in 59.1026ms info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1] Executed endpoint '/Index' info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 GET http://localhost:5000/ - 200 - text/html;+charset=utf-8 116.7429ms info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 GET http://localhost:5000/lib/bootstrap/dist/css/bootstrap.min.css - - - info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 GET http://localhost:5000/lib/bootstrap/dist/css/bootstrap.min.css - 404 0 - 2.9657ms info: Microsoft.AspNetCore.Hosting.Diagnostics[16] Request reached the end of the middleware pipeline without being handled by application code. Request path: GET http://localhost:5000/lib/bootstrap/dist/css/bootstrap.min.css, Response status code: 404 info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 GET http://localhost:5000/css/site.css - - - info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 GET http://localhost:5000/razortest.styles.css - - - info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 GET http://localhost:5000/razortest.styles.css - 404 0 - 0.4805ms info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 GET http://localhost:5000/css/site.css - 404 0 - 1.4374ms info: Microsoft.AspNetCore.Hosting.Diagnostics[16] Request reached the end of the middleware pipeline without being handled by application code. Request path: GET http://localhost:5000/razortest.styles.css, Response status code: 404 info: Microsoft.AspNetCore.Hosting.Diagnostics[16] Request reached the end of the middleware pipeline without being handled by application code. Request path: GET http://localhost:5000/css/site.css, Response status code: 404 info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 GET http://localhost:5000/lib/jquery/dist/jquery.min.js - - - info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 GET http://localhost:5000/lib/jquery/dist/jquery.min.js - 404 0 - 0.0561ms info: Microsoft.AspNetCore.Hosting.Diagnostics[16] Request reached the end of the middleware pipeline without being handled by application code. Request path: GET http://localhost:5000/lib/jquery/dist/jquery.min.js, Response status code: 404 info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 GET http://localhost:5000/lib/bootstrap/dist/js/bootstrap.bundle.min.js - - - info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 GET http://localhost:5000/lib/bootstrap/dist/js/bootstrap.bundle.min.js - 404 0 - 0.0735ms info: Microsoft.AspNetCore.Hosting.Diagnostics[16] Request reached the end of the middleware pipeline without being handled by application code. Request path: GET http://localhost:5000/lib/bootstrap/dist/js/bootstrap.bundle.min.js, Response status code: 404 info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 GET http://localhost:5000/js/site.js - - -

.NET Version

.NET SDK: Version: 8.0.200-preview.24064.2 Commit: 3662b97225 Workload version: 8.0.200-manifests.9f3f18d7

Runtime Environment: OS Name: Windows OS Version: 10.0.25398 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.200-preview.24064.2\

.NET workloads installed: There are no installed workloads to display.

Host: Version: 8.0.0 Architecture: x64 Commit: 5535e31a71

.NET SDKs installed: 8.0.200-preview.24064.2 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: None

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

Anything else?

No response

v-ainigao commented 7 months ago

This problem is also reproduced on Win ARM64.

vdanche commented 7 months ago

Also happens on 9.0.100-alpha.1.24066.10 SDK

javiercn commented 7 months ago

Can't you point here to the test case where this is defined. The steps are wrong.

I am not able to reproduce it locally. What's likely happening is that you are invoking dotnet <<path-to-dll>> from the solution folder instead of from inside razortest hence why it's not able to find the wwwroot folder.

This behavior hasn't changed.

ghost commented 7 months ago

Hi @vdanche. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

vdanche commented 7 months ago

@javiercn I see what you mean, we re-check our steps, I did invoke dotnet <> from the solution folder instead of from inside razortest. so this warning is expected, right? one more thing, if we invoke dotnet <<path-to-dll>> from the solution folder instead of from inside razortest, open the link http://localhost:5000/, it show as below and it's also expected? image

I access to razortest, and then dotnet <<path-to-dll>>, the issue will not happen. image

ghost commented 7 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.

vdanche commented 7 months ago

@javiercn I see what you mean, we re-check our steps, I did invoke dotnet <> from the solution folder instead of from inside razortest. so this warning is expected, right? one more thing, if we invoke dotnet <<path-to-dll>> from the solution folder instead of from inside razortest, open the link http://localhost:5000/, it show as below and it's also expected? image

I access to razortest, and then dotnet <<path-to-dll>>, the issue will not happen. image

@javiercn if it's expected that must invoke dotnet <> from inside razortest instead of from the solution folder, then it's also expected that the http://localhost:5000/ link cannot display normally, because we invoke dotnet <> from the solution folder. we'll not keep track this issue any more. Thanks.🙂

SubbuRamanathan commented 4 months ago

I faced the same issue with VS Code but interestingly when I upgraded Visual Studio 2022 and tried from VS2022, the sites were working fine without any issues