creating a Map.Path to another application

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.
 
M

Michael C#

That's the HttpRequest .MapPath() method with the overloads, not the
Server.MapPath() method.
 
G

Guest

Is is possible to do this with the Server.MapPath() method, as in refer to an
outside application?
 
M

Michael C#

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top