3

I am currently trying to associate Apple Pay with a website. In order to verify the domain, Apple Pay requires that the website be able to serve a specific static file at https://websiteurl/.well-known/apple-developer-merchantid-domain-association.

I am currently unable to get my website to serve this static file. I am able to serve other static files, just not this specific one. I suppose the problem has something to do with the period in the directory name. I have tried to follow suggestions from this question but without success.

My wwwroot directory structure looks like this:

wwwroot
    .well-known
        apple-developer-merchantid-domain-association
        web.config
    App_Data
    Content
    css
    js
        app.js
    lib

the contents of .well-known -> web.config is:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension="." mimeType="application/octet-stream" />
    </staticContent>
  </system.webServer>
</configuration>

I believe this is what what described in the accepted answer in this question.

However, when I attempt to access https://websiteurl/.well-known/apple-developer-merchantid-domain-association, I get an HTTP 404 error.

I verified that I can access static files successfully because https://websiteurl/js/app.js works successfully.

I also tried putting web.config directly under wwwroot

Not sure what I am doing wrong. Any suggestions?

Mike Moore
  • 1,330
  • 1
  • 14
  • 20

2 Answers2

7

Turns out the problem was not the period in the directory name, but rather the lack of extension on the file. The following code in Startup.cs solved the problem:

    app.UseStaticFiles();
    app.UseStaticFiles(new StaticFileOptions    
    {
         FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/.well-known")),
         RequestPath = "/.well-known",
         ServeUnknownFileTypes = true,
         DefaultContentType = "text/plain"
     });
Rudi Visser
  • 21,350
  • 5
  • 71
  • 97
Mike Moore
  • 1,330
  • 1
  • 14
  • 20
0

Try FileServer :

public void Configure(IApplicationBuilder app)
{
    app.UseStaticFiles();

    app.UseFileServer(new FileServerOptions
    {
        FileProvider = new PhysicalFileProvider(
            Path.Combine(Directory.GetCurrentDirectory(), "MyStaticFiles")),
        RequestPath = "/wwwroot",
        EnableDirectoryBrowsing = true
    });
}
XAMT
  • 1,515
  • 2
  • 11
  • 31