creating a Map.Path to another application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have two web apps. Lets say main and admin for the sake of simplicity.
admin is a web app within main (as a subdomain). So the path for admin is
http://admin.main.com

within the admin application I have a file upload page and I wish to upload
the files to the main application. I have tried this application of MapPath
and it fails.

string myPath = "http://main.com"
bool allow = true;

txtUpload1.PostedFile.SaveAs(Server.MapPath(myPath,"MainDirectory", allow) +
"\\" + file1.Name);

I get this error message on compile:
No overload for method 'MapPath' takes '3' arguments

According to the documentation It can be overloaded with 3 arguments,
specifically for this purpose of creating a path to another application.
 
That's the HttpRequest .MapPath() method with the overloads, not the
Server.MapPath() method.
 
Is is possible to do this with the Server.MapPath() method, as in refer to an
outside application?
 
HttpServerUtility.MapPath() method "returns the physical file path that
corresponds to the specified virtual path on the Web server." If
Application 1 knows the virtual path of Application 2, then just plug it in
and go. Or you might set up a shared directory somewhere (which is what I
would probably do, to keep conflicts to a minimum). Keep in mind that the
"virtual directory" that this application of MapPath is looking for is the
IIS Virtual Dir, not necessarily the Domain that you're trying to pass.
 
Back
Top