使用 Asp.Net 获取服务器上 Web 应用程序文件夹之外的数据库路径

发布于 2024-12-07 07:58:45 字数 261 浏览 3 评论 0原文

我向服务器发布了一个 Web 应用程序,我想访问一个数据库文件 (.mdb),该文件也存储在服务器上与我的服务器不同的位置。如何在我的 Asp.Net 应用程序的 web.config 文件中执行此操作?

<add name="MyOleDbConnection" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source= **{?}** \inventory.mdb"/>

I published a web app to a server and I would like to access a database file (.mdb) that is also stored on the server in a different location outside of mine. How can I do this in the web.config file of my Asp.Net app?

<add name="MyOleDbConnection" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source= **{?}** \inventory.mdb"/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

歌入人心 2024-12-14 07:58:45

我不相信你可以通过代码,使用诸如 Server.MapPath() 之类的东西来做到这一点 - 并且有充分的理由。这将允许开发人员编写接管云服务器上主机操作系统的应用程序。您无法确定 IIS 控制之外的文件/文件夹的路径,以防止目录遍历攻击。

您需要询问系统管理员或有权访问该计算机上的路径的人员。获得完整路径后,您可以在 .config 中设置完整路径,

c:\path\inventory.mdb

而不是

\inventory.mdb

您还需要确保系统管理员授予您访问 .mdb 的权限。

I don't believe you can do it from code, using anything like Server.MapPath() - and for good reason. This would allow developers to write apps that take over host operating systems on cloud servers. You're restricted from determining the path of files/folders outside of the control of IIS to prevent directory traversal attacks.

You'll need to ask a SysAdmin, or someone who has access what the path is on that machine. Once you have the full path, you can set the full path in the .config

c:\path\inventory.mdb

instead of

\inventory.mdb

You will also need to make sure that the SysAdmin grants you permissions to access the .mdb.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文