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

Blazor (client side) hosted in IIS not working under AspNetCore 3 Preview 6 #11425

Closed
JoelW187 opened this issue Jun 20, 2019 · 3 comments
Closed
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue

Comments

@JoelW187
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

Hosting Blazor apps in IIS doesn't seem to work under Preview 6. I always get the message "This localhost page can’t be found" (in Chrome). The app runs fine in Visual Studio 2019 Preview (16.2.0 Preview 2.0). But when I publish the code to an IIS website I get the error. I'm thinking it has something to do with the new MapFallbackToClientSideBlazor call in Startup.Configure (but that's just a guess).

To Reproduce

Steps to reproduce the behavior:

  1. I installed the preview 6 SDK and the Hosting Bundle (from https://dotnet.microsoft.com/download/dotnet-core/3.0)
  2. In Visual Studio Professional 2019 Preview (16.2.0 Preview 2.0) I created a Blazor hosted project and verified that the Preview 6 packages were referenced. This project runs correctly in Chrome within VS 2019/IIS Express.
  3. Publish the web site (I used a File publish on my local machine) and setup an application in IIS for the site (app pool = No Managed Code, No 32-bit, Integrated, ApplicationPoolIdentity)
  4. Navigate to the new site in Chrome. I get the message "This locahost page can't be found"
  5. If I start the executable (WindowsApplication1.Server.exe) from the command line and navigate to http://localhost:5000 I also get the error message (I swear this worked once but it doesn't work now).

Expected behavior

I expected the site to run

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.
Here's what I get at the command line when I start the executable and navigate to port 5000:
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\joel.wilson\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at r
est.
Hosting environment: Production
Content root path: c:\junk\pre6\WebApplication1\WebApplication1.Server\bin\Debug\netcoreapp3.0\publish
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://localhost:5000/
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'Fallback {*path:nonfile}'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'Fallback {*path:nonfile}'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 41.8796ms 404

It doesn't seem to be routing to the fallback path correctly (which is set in Startup.cs with the following code:
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
endpoints.MapFallbackToClientSideBlazor<Client.Startup>("index.html");
});
)

But, again, it runs fine under IISExpress/Visual Studio 2019 Preview.

dotnetinfo6.txt

@Eilon Eilon added the area-blazor Includes: Blazor, Razor Components label Jun 20, 2019
@JoelW187
Copy link
Author

I figured out the issue and I think it's the Visual Studio Publisher. When you publish it creates a wwwroot folder but it's not putting index.html (or the css folder, in this case) under wwwroot. Instead it creates folders under wwwroot called _content\webapplication1client which contain index.html (and my css folder). I copied these to the wwwroot folder and the app runs now -- no 404. So it looks like the hosting bundle works fine but VS2019 publisher is not creating the correct folder structure. So there is a workaround but it's a pain-in-the-*** to have to fix up the folders after a publish.

@danroth27
Copy link
Member

@javiercn Is perhaps related to the static assets work?

@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @JoelW187.
This is being tracked as part of #11185

@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Jun 21, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 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 ✔️ Resolution: Duplicate Resolved as a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants