Hi @NIKITA HANDE,
We highly recommend putting static resources in the wwwroot
folder. It is not recommended to put it anywhere else, as this will protect the security of your static resources.
The middleware UseStaticFiles(default settings) only supports reading the contents of the wwwroot folder, so this is the reason why you encounter 404 when reading resources in the root directory.
If you want to read the resources in the root directory, you can do so in the following ways .
Please note that this is not the recommended approach.
1.My Project Sample
2.We need to add follow code in Program.cs
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory())),
RequestPath = ""
});
app.UseRouting();
app.UseAuthorization();
3.Test Result
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Jason