Include .well-known folder in your asp.net core project
.well-known/acme-challenge/***not found (http 404)
If you want to use Let’s Encrypt, choose the manual way and pass the value http for the –preferred-challenges argument to generate a certificate, you may get a not found (404) HTTP response for a file inside this folder.
For my example, I created the .well-known directory inside the wwwroot directory.
To resolve this issue, you need to add the following statement:
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 adding a few using directives:
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 to the csproj file of your project:
<ItemGroup>
<Content Include="wwwroot\.well-known\acme-challenge\**" />
</ItemGroup>