Adrien Clerbois' blog

Software Craftmanship @ Sense Of Tech, Microsoft MVP Developer Technologies

Include .well-known folder in your core project

Include .well-known folder in your core project

.well-known/acme-challenge/***not found (http 404)

In case where you want to use Let’s Encrypt and you choose the manual way and passing the value http for the –preferred-challenges argument to generate a certificate. You should have not found (404) http response for a file inside this folder.

For my example, I create the directory .well-known inside the wwwroot directory.

To resolve this issue you need to add the following statement to solve it:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
            // ...
            app.UseStaticFiles(new StaticFileOptions
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot/.well-known")),
                RequestPath = new PathString("/.well-known"),
                ServeUnknownFileTypes = true // serve extensionless file
            // ...

You should add this configuration statement after the line app.UseStaticFiles();.

This statement requires to add some using :

  • using System.IO;
  • using Microsoft.Extensions.FileProviders;
  • using Microsoft.AspNetCore.Http

The folder may not appear in Visual Studio. You can add the following configuration lines in the csproj file of your project :

        <Content Include="wwwroot\.well-known\acme-challenge\**" />