How to host apple-app-site-association file using Blazor WASM

36 Views Asked by At

I created a well-known folder under wwwroot and added my apple-app-site-association.json file along with a Web.config file. I then created a Virtual path in Azure.

enter image description here

This does not work.

The next thing I tried was adding a WellKnown Razor page and serving up the json file.

@page "/well-known/apple-app-site-association"
@layout NoMenuLayout

This works (json file downloads), but it doesn't pass the apple-app-site-association validation test.

The next thing I tried was adding a .WellKnown Razor page and serving up the json file.

@page "/.well-known/apple-app-site-association"
@layout NoMenuLayout

This does not work and certainly won't pass the apple-app-site-association validation test.

This is how my file download currently works.

https://stackoverflow.com/a/75074836/5360237

UPDATE 1

The following method works to download the file on both the WellKnown and .WellKnown Razor pages. It does not pass validation, though. This is the error type message from the validation page. "Your file's 'content-type' header was not found or was not recognized".

NOTE: I had to remove the .well-known Virtual path in Azure.

private async Task DownloadFileFromURL()
{
    var fileName = "apple-app-site-association.json";
    var fileURL = "/well-known/apple-app-site-association.json";
    await JS.InvokeVoidAsync("triggerFileDownload", fileName, fileURL);
}


protected override async Task OnInitializedAsync()
 {  
     await DownloadFileFromURL();
 }
<script>
    window.triggerFileDownload = (fileName, url) => {
        const anchorElement = document.createElement('a');
        anchorElement.href = url;
        anchorElement.download = fileName ?? '';
        anchorElement.click();
        anchorElement.remove();
    }
</script>

Does anyone know how to correctly configure this? Thanks!

0

There are 0 best solutions below