Skip to content

Commit

Permalink
Fix .NET 6 case (#31165)
Browse files Browse the repository at this point in the history
* Fix .NET 6 case

* Fix .NET 6 case

* Fix .NET 6 case

* react to feedback

* react to feedback
  • Loading branch information
Rick-Anderson authored Dec 6, 2023
1 parent 1b8608c commit ae56b26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
#region snippet1
var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseWebRoot("wwwroot");
builder.WebHost.UseStaticWebAssets();
builder.WebHost.UseWebRoot("wwwroot").UseStaticWebAssets();

builder.Services.AddRazorPages();

Expand Down
4 changes: 3 additions & 1 deletion aspnetcore/razor-pages/ui-class/includes/ui-class6.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ The consuming app references static assets provided by the library with `<script

When running the consuming app from build output (`dotnet run`), static web assets are enabled by default in the Development environment. To support assets in other environments when running from build output, call <xref:Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.UseStaticWebAssets%2A> on the host builder in `Program.cs`:

[!code-csharp[](~/razor-pages/ui-class/6samples/cli/WebApp1/Program.cs?name=snippet1&highlight=3-4)]
[!code-csharp[](~/razor-pages/ui-class/6samples/cli/WebApp1/Program.cs?name=snippet1&highlight=3)]

***Note:*** .NET 6 only requires calling `builder.WebHost.UseWebRoot("wwwroot").UseStaticWebAssets`. For more information, see [this GitHub issue](https://github.com/dotnet/aspnetcore/issues/38212).

Calling `UseStaticWebAssets` isn't required when running an app from published output (`dotnet publish`).

Expand Down

0 comments on commit ae56b26

Please sign in to comment.