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

[Preview 8] static assets not found when launchSettings.json is missing #13190

Closed
akorchev opened this issue Aug 16, 2019 · 2 comments
Closed
Labels
area-blazor Includes: Blazor, Razor Components question

Comments

@akorchev
Copy link

If you believe you have an issue that affects the security of the platform please do NOT create an issue and instead email your issue details to secure@microsoft.com. Your report may be eligible for our bug bounty but ONLY if it is reported through email.

Describe the bug

If the Properties/launchSettings.json file is missing static assets from Razor class libraries no longer seem to work. They all lead to HTTP 404 status.

To Reproduce

Steps to reproduce the behavior:

  1. Create a blazorserver application using Preview 8: dotnet new blazorserver
  2. Install a third party library that has static assets e.g. Blazored.Toast: dotnet add package Blazored.Toast
  3. Include its CSS file by adding this line to _Host.cshtml: <link href="_content/Blazored.Toast/blazored-toast.css" rel="stylesheet" />
  4. Run the application dotnet run and open the asset by loading https://localhost:5001/_content/Blazored.Toast/blazored-toast.css. You should see the file content.

image

  1. Stop the application and delete the launchSettings.json file from the Properties directory rm -rf Properties/launchSettings.json
  2. Run the application dotnet run and open the asset by loading https://localhost:5001/_content/Blazored.Toast/blazored-toast.css. It is no longer found.

image

Expected behavior

The assets should work with or without launchSettings.json.

@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Aug 16, 2019
@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @akorchev.
The StaticWebAssets feature works only in Development by default. You can turn on the feature unconditionally by calling UseStaticWebAssets in the Program.CreateHostBuilder.

@akorchev
Copy link
Author

FWIW static assets seem to work just fine in production without calling UseStaticWebAssets or having launchSettings.json. It is probably something else that is causing UseStaticWebAssets to be invoked.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components question
Projects
None yet
Development

No branches or pull requests

2 participants