How do I fix static assets not showing on implementing project with .Net9

William Mendoza 0 Reputation points
2024-12-24T20:51:38.42+00:00

Hi, I am having an issue in my app when trying to implement a Nuget package.

My project has the following configuration:
<ItemGroup>

<!-- Include the JavaScript file in the NuGet package -->

<Content Include="wwwroot\**\*">

<Pack>true</Pack>

<CopyToOutputDirectory>Always</CopyToOutputDirectory>

</Content>

<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />

<PackageReference Include="Microsoft.JSInterop" Version="9.0.0" />

<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

</ItemGroup>

and it shows properly in my project:
User's image

But when I access the file I get a blank page:
User's image

if I try the compressed version I can see the code:
User's image

The _content url does not work:
User's image

//the nuspec file shows:
<contentFiles>

<files include="any/net9.0/wwwroot/scripts/invokegooglecaptcha.js" buildAction="Content" />

</contentFiles>

I reference the file like this:
<script src="@Assets["/scripts/invokegooglecaptcha.js"]" type="text/javascript"></script>

I searched through the documentation but I could not resolve it. Any help is appreciated it. Thank you.

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,636 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.