How to Add a .well-known Folder to Your ASP.Net Application

Since a few people had troubles with creating the .well-known folder for the security.txt in ASP.Net, I will explain in this post how you can do it in .Net 4.8 and .Net 6.

 

.Net 4.8

In .Net 4.8 it is almost too easy to figure out how to do it. You create the .well-known folder directly in the top-level of your web application project next to the folders App_Start and App_Data:

Create the .well-known folder next to App_Start folder

Inside the .well-known folder you place your security.txt file. Run your application and you can access the file without authorisation in this location:
https://your-site.com/.well-known/security.txt

 

.Net 6+

The template in .Net 6 helps you with a clear place to put our folder. Create the .well-known folder inside the folder wwwroot and then add the security.txt file:

Put your .well-known folder into the wwwroot folder

If you start your application, you can access the file here:
https://your-site.com/.well-known/security.txt

Should you get an error instead, make sure you have this entry in Program.cs:

 

Conclusion

The .well-known folder in .Net 4.8 is one of those examples where it’s easy if you know how to do it, and impossible if you don’t. I hope this post helps you to create such a folder in your ASP.net application without spending hours to figure out the right solution.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.