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, clickOK - Select
Blazor (ASP.NET Core hosted) - Right-click
BlazorDotNetHosted.Serverand select Publish - Select
Folder, note it’s going tobin\Release\netcoreapp2.1\publish\, click Publish - Create local folder at
D:\apps\web\BlazorDotNetHosted - Copy+paste contents at
bin\Release\netcoreapp2.1\publish\toD:\apps\web\BlazorDotNetHosted - Open IIS, navigate to
Default Web Site - Right-click
Default Web Siteand selectAdd Application - Alias:
BlazorDotNetHosted, Application Pool:DefaultAppPool, Physical path:D:\apps\web\BlazorDotNetHosted, clickOK - Click
Browse..to view the app athttp://localhost/BlazorDotNetHosted/and note that the page just saysLoading...
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)
@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.