Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

105
Vistas
Add .well-known to asp.net core

I want to have a .well-known directory in my root for letsencrypt renewals.

I have added a route to .well-known like so:

 app.UseStaticFiles(new StaticFileOptions
        {
            FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @".well-known")),
            RequestPath = new PathString("/.well-known"),
            ServeUnknownFileTypes = true // serve extensionless file
        });

I added a direcotry inside my wwwroot called .well-known but it never gets copied to the output when I publish.

I tried adding a file to it and also edit csproj:

  <ItemGroup>
    <Content Include="wwwroot\.well-known\" />
  </ItemGroup>

Every time I publish I have to manually create the directory. How do I get it automatically added to the wwwroot?

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

I tried adding a file to it and also edit csproj:

<ItemGroup>
  <Content Include="wwwroot\.well-known\" />
</ItemGroup>

You can't copy over folders via Content, only files. You have to change it to

<ItemGroup>
  <Content Include="wwwroot\**">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
<ItemGroup>

and like mentioned in the comments, you need to put an empty dummy file inside.

about 4 years ago · Santiago Trujillo Denunciar

0

Another approach is to make a controller - if you have complex rules - or the file varies by domain (as it does for certain types of verification tokens).

public class WellKnownFileController : Controller
{
    public WellKnownFileController()
    {

    }

    [Route(".well-known/apple-developer-merchantid-domain-association")]
    public ContentResult AppleMerchantIDDomainAssociation()
    {
        switch (Request.Host.Host)
        {
            case "www2.example.com":
                return new ContentResult
                {
                    Content = @"7B227073323935343637",
                    ContentType = "text/text"
                };

            default:
                throw new Exception("Unregistered domain!");
        }
    }
}

You can then just hit .well-known/apple-developer-merchantid-domain-association and get this controller.

Of course you can load the file from disk or whatever you need to do - or have a passthrough.

about 4 years ago · Santiago Trujillo Denunciar

0

you can add the below code to the MyProject.csproj file

  <ItemGroup>
    <Content Include=".well-known\acme-challenge\**">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda