【问题标题】:asp.net mvc secure folder containing random file extension包含随机文件扩展名的 asp.net mvc 安全文件夹
【发布时间】:2019-05-14 18:43:56
【问题描述】:

我正在开发 Asp.net MVC 应用程序。应用程序包含一个需要防止未经授权访问的文件夹。客户可以将具有任何扩展名的文件复制到此文件夹。客户不希望未经授权的人(未登录的人)通过直接访问浏览器 URL 中的文件来下载文件。

我不能使用 httpHandler,因为我们事先不知道文件的扩展名。 我还尝试在其授权部分保留单独的 web.config 和 <deny users="?"/>。但它仅适用于已知扩展名,对于未知扩展名会出现以下错误,

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

有人可以建议如何处理这种情况吗?

谢谢。

【问题讨论】:

    标签: c# asp.net security directory file-extension


    【解决方案1】:

    您可以将它们作为二进制数组存储在数据库中,而不是将服务器上的物理文件存储在安全文件夹中。然后使用通用处理程序来获取文件。

    例如:https://example.com/SecuredFolder/Readfile?id=12345

    然后您可以通过编程方式在响应中设置Content-Type

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多