如何从ASP.NET中的子域应用程序访问主域目录 [英] How to access main domain directory from subdomain application in ASP.NET

查看:96
本文介绍了如何从ASP.NET中的子域应用程序访问主域目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有主域名www.abc.com和子域名crm.abc.com我想将图像从子域名上传到主domian目录 - www.abc.com/images/users



我的尝试:



string foloderLocation = Server.MapPath(〜/ images / users / + filename;

I have main domain www.abc.com and subdomain crm.abc.com I want to upload an image from subdomain to main domian directory -- www.abc.com/images/users

What I have tried:

string foloderLocation = Server.MapPath("~/images/users/" +filename);

推荐答案

最简单的选择是使用IIS在CRM站点中添加指向主站点上文件夹的虚拟目录。然后,您可以使用 MapPath 来获取文件夹的物理路径:

The simplest option would be to use IIS to add a virtual directory in the CRM site pointing to the folder on the main site. You could then use MapPath to get the physical path of the folder:
string folderLocation = Server.MapPath("~/main-site-images/users/" + filename);



如果由于某种原因无法做到这一点,那么你需要指定物理路径直。您可能希望将它放在配置文件中,这样您就不必在每次路径更改时重新编译。


If you can't do that for some reason, then you'll need to specify the physical path directly. You'll probably want to put it in your config file, so that you don't have to recompile every time the path changes.

string folderLocation = System.IO.Path.Combine(WebConfigurationManager.AppSettings["mainSiteImagesPath"], "users", filename);


这篇关于如何从ASP.NET中的子域应用程序访问主域目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆