aspnetcore: Unable to host in IIS on Windows 10 as an application

I am unable to get Blazor working using the Blazor (ASP.NET Core hosted) template while hosting the application as an IIS application on my local Windows 10 machine.

  • File, New Project, ASP.NET Core Web Application
  • Name: BlazorDotNetHosted, click OK
  • Select Blazor (ASP.NET Core hosted)
  • Right-click BlazorDotNetHosted.Server and select Publish
  • Select Folder, note it’s going to bin\Release\netcoreapp2.1\publish\, click Publish
  • Create local folder at D:\apps\web\BlazorDotNetHosted
  • Copy+paste contents at bin\Release\netcoreapp2.1\publish\ to D:\apps\web\BlazorDotNetHosted
  • Open IIS, navigate to Default Web Site
  • Right-click Default Web Site and select Add Application
  • Alias: BlazorDotNetHosted, Application Pool: DefaultAppPool, Physical path: D:\apps\web\BlazorDotNetHosted, click OK
  • Click Browse.. to view the app at http://localhost/BlazorDotNetHosted/ and note that the page just says Loading...

Things I’ve tried:

Update the app base path as suggested here by opening the index.html at D:\apps\web\BlazorDotNetHosted\BlazorDotNetHosted.Client\dist\index.html and edit the base element to add the path:

<base href="/BlazorDotNetHosted/" />

This does allow the application to load. However the links don’t work as the navbar-brand, Counter, and Fetch Data links are localhost, localhost/counter, and localhost/fetchdata. I even tried installing the URL Rewrite Module as suggested here.

If I manually navigate to localhost/BlazorDotNetHosted/counter that page works.

If I manually navigate to http://localhost/BlazorDotNetHosted/fetchdata it loads the page but the api call in Chrome Dev tools shows 404 not found on http://localhost/api/SampleData/WeatherForecasts.

If I hit the api at http://localhost/BlazorDotNetHosted/api/SampleData/WeatherForecasts that returns data successfully.

I feel like I’m very close but I’m unsure of how to get it to respect the base element. Am I doing something wrong or is this not supported? Does it have to be deployed to the root of a web server or hosted in app service at the root url?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

@AnkitSharma-007 you’re creating that as a SITE not an APPLICATION under an existing site. The work-around I mentioned is doing what you are doing.