从子域应用程序访问主域文件夹中的文件
我在子域中有一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
然后您必须指定完整的 url,如
c:/wwwroot/site/file.xml
Then you will have to specify the full url like
c:/wwwroot/site/file.xml
或者您可以只创建一个符号链接(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.