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

Notyf doesn't work when ASPNETCORE_ENVIRONMENT is set to "PRODUCTION" in launchSettings.json #14

Open
zeecorleone opened this issue Jun 30, 2022 · 2 comments

Comments

@zeecorleone
Copy link

zeecorleone commented Jun 30, 2022

My _Layout cshtml file (in dotnet 5 MVC app) looks something like following, and the Notyf had been working smoothly so far.

<script src="~/js/site.js" asp-append-version="true"></script>
<script src="~/js/controls.js" asp-append-version="true"></script>

@await Component.InvokeAsync("Notyf")
@await RenderSectionAsync("Scripts", required: false)

Now I added <environment> like following, and in order to test this scenario, I changed ASPNETCORE_ENVIRONMENT to PRODUCTION in my launchSettings.json.

<script src="~/js/site.js" asp-append-version="true"></script>
<script src="~/js/controls.js" asp-append-version="true"></script>

<environment names="Staging,Production">
<script src="~/js/somefile.js" asp-append-version="true"></script>
</environment>

@await Component.InvokeAsync("Notyf")
@await RenderSectionAsync("Scripts", required: false)

After this, the Notyf doesn't load properly, and I'm always getting following errors:

image

image

Soon as I set ASPNETCORE_ENVIRONMENT to DEVELOPMENT, all works fine as always.

Is there something I'm doing wrong? Or is it some bug? Any help will be appreciated.

I posted more details at StackOverflow Here

@gamerwalt
Copy link

This I CAN VERIFY. This just happened to me and I was about to push to PRODUCTION. And wondering WTF is going on. Beautiful catch.

@ClassyCircuit
Copy link

That is because you haven't loaded static web assets.
In Program.cs -> WebHostBuilder method:

StaticWebAssetsLoader.UseStaticWebAssets(context.HostingEnvironment, context.Configuration);

Read the first answer here for more info: https://stackoverflow.com/questions/72811673/notyf-view-component-not-working-when-using-environment-tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants