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.cs
kicks in successfully -Console.WriteLine
statements inProgram.cs
andStartUp.cs
prove 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 href
as "/" inwwwroot\index.html
- define the
base href
as "/dist" inwwwroot\index.html
- define the route in an
index.cs
file using a[Route]
attribute - dynamic define the
base href
inwwwroot\index.html
at 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 href
after the content has loaded, when thebase href
should be part of thehead
section? Does that make a difference? – Jamie Reesbase href
in thebody
makes no difference (surprisingly). when I set thebase href
in thebody
to 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 href
in thehead
to what I am convinced is the correct value fails :-( – Greg Trevellick