I have a simple Blazor website (source code) which has a routing issue when running in an iframe on Azure Devops but not elsewhere.
The application works fine when running under the following conditions
- locally on my PC using Visual Studio (VS2019) using 'F5'
- locally as a static site after having published the project to disc using the Visual Studio 'Publish' function
- locally as a static site within an iframe of another unrelated site
- remotely as a hosted static site after uploading the published site to a host
- remotely as a static site within an iframe of another unrelated site (this second static site mimics AzureDevOps boards, using a different host name)
However when I generate an Azure Devops widget and upload it to the Visual Studio Marketplace Blazor routing fails and therefore the site fails to load correctly, as per this screenshot.
[
The source code for the site (which nothing more than a simplified version of the default VS Blazor template) can be found here.
Observations
- all the blazor-related assets (i.e. Blazor & mono javascript files & various DLL files) are served up to the browser successfully
- the blazor DLL runs successfully (i.e.
Programs.cskicks in successfully -Console.WriteLinestatements inProgram.csandStartUp.csprove this) - blazor fails to successfully find the default route and hence the
<NotFoundContent>(defined inApp.razor) tag is displayed within the Azure Devops iframe
Things I have tried to solve the issue
- define the
base hrefas "/" inwwwroot\index.html - define the
base hrefas "/dist" inwwwroot\index.html - define the route in an
index.csfile using a[Route]attribute - dynamic define the
base hrefinwwwroot\index.htmlat runtime using javascript (this caters for any changes to the iframe parent URL by Microsoft)
Notes
- all Azure Devops widgets run inside an iframe within Azure Devops.
- the vsix file that was uploaded to Visual Studio Marketplace can be found here.
base hrefafter the content has loaded, when thebase hrefshould be part of theheadsection? Does that make a difference? - Jamie Reesbase hrefin thebodymakes no difference (surprisingly). when I set thebase hrefin thebodyto a wrong value such as 'foobar' the assets fail to download, but when set to the correct value the assets do download. Even setting thebase hrefin theheadto what I am convinced is the correct value fails :-( - Greg Trevellick