从子域应用程序访问主域文件夹中的文件

发布于 2024-12-03 17:09:21 字数 367 浏览 9 评论 0原文

我在子域中有一个 Web 应用程序,我想在其中保留对主域中文件的访问权限。这可能吗?

HttpContext.Current.Server.MapPath("../www/file.xml"));

其中“www”在主文件夹中。 “../”不起作用。

要一清二楚。我正在尝试将 xml 文件加载到 XDocument 对象中:

Data = XDocument.Load(HttpContext.Current.Server.MapPath("~/App_Data/file.xml");

工作正常。但我希望路径位于主域的文件夹中。我怎样才能做到这一点?如果可能的话:)

I have a web app in a subdomain, where I want to uptain access to a file located in the main domain. Is that possible?

HttpContext.Current.Server.MapPath("../www/file.xml"));

Where "www" in the main folder. The "../" doesnt work.

To be crystal clear. Im trying to load a xml file into a XDocument object:

Data = XDocument.Load(HttpContext.Current.Server.MapPath("~/App_Data/file.xml");

Works fine. But I want the path to be in a folder on the main domain. How can I do that? If its possible :)

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

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

发布评论

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

评论(2

九命猫 2024-12-10 17:09:21

然后您必须指定完整的 url,如 c:/wwwroot/site/file.xml

Then you will have to specify the full url like c:/wwwroot/site/file.xml

香橙ぽ 2024-12-10 17:09:21

或者您可以只创建一个符号链接(cmd 中的 mklink 命令)并使用它,就像它是子域目录中的文件夹一样。
您需要管理员权限才能创建符号链接。

Or you can just create a symlink (mklink command in cmd) and use it just as if it were a folder inside your subdomain directory.
You need an admin privileges do create a symlink.

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