简体   繁体   English

如何限制存储在 wwwroot 文件夹下的 json 文件从 Web 浏览器查看

[英]How to restrict json files that are stored under wwwroot folder to view from Web Browser

I have a " client-styles.css " in my wwwroot / client_folder folder.我的wwwroot / client_folder文件夹中有一个“ client-styles.css ”。 When I run my project in localhost and give that css file path in the browser its showing the entire css file in the web browser.当我在 localhost 中运行我的项目并在浏览器中提供 css 文件路径时,它会在 web 浏览器中显示整个 css 文件。 ( localhost:5000/client_folder/client-styles.css ). (本地主机:5000/client_folder/client-styles.css)。

In the same way I have a folder also contains json files which contains sensitive information and those are also showing if we give the path to those Json files ( localhost:5000/client_folder/client-secrets.json ) in the browser.同样,我有一个文件夹还包含json 文件,其中包含敏感信息,如果我们提供这些 Json 文件的路径,这些文件也会显示(localhost:5000/client_folder/client-secrets.Z466DEEC76ECDF5FCA6D35 中的浏览器) Is there any way restricting some files to view from web browser.有什么方法可以限制某些文件从 web 浏览器查看。

Thanks谢谢

Based on your last comment above:根据您上面的最后评论:

It's perfectly acceptable to store css and javascript files in wwwroot.将 css 和 javascript 文件存储在 wwwroot 中是完全可以接受的。 However, do not store anything secret there.但是,不要在那里存储任何秘密。 Storing secrets like connectionstrings are best in EnvironmentVariables.在 EnvironmentVariables 中最好存储连接字符串之类的秘密。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从wwwroot内的文件夹提供静态文件 - Serve static files from a folder inside wwwroot 从wwwroot文件夹删除文件,我在做什么错? - Deleting files from wwwroot folder, what I am doing wrong? 是否可以从wwwroot文件夹外部提供静态文件? - Is it possible to serve static files from outside the wwwroot folder? 如何访问不同项目的 wwwroot 文件夹中的文件? - How to access files within the wwwroot folder of a different project? 在wwwroot下部署自定义静态文件夹 - Deploying a custom static folder under wwwroot 显示来自wwwroot文件夹的图像 - Displaying images from wwwroot folder “wwwroot”文件夹中的某些文件未在 ASP.NET 核心 web 部署中发布 - Some files in "wwwroot" folder are not published in ASP.NET Core web deploy 如何重命名ASP.NET 5 Web项目中用作Web根的“ wwwroot”文件夹 - How to rename “wwwroot” folder used as web root in ASP.NET 5 web project 如何从 .net 中 wwwroot 内的多个文件夹中提供 html 文件 - How to serve html files from multiple folders inside wwwroot in .net 从 Asp.net 内核 Web API 3.1 “wwwroot”之外的文件夹加载图像 - Loading Image from Asp.net core Web API 3.1 Folder outside of “wwwroot”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM