Add .well-known to asp.net core
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.
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.
you can add the below code to the MyProject.csproj
file
<ItemGroup>
<Content Include=".well-known\acme-challenge\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>