Reputation: 196781
i have multiple websites on the same server. I want to have a link from one to another but i can't seem to have relative paths because it seems that Server.MapPath cant go "below" the root of the current website.
how do i have one website on my machine point to a file or page that is on another one.
Upvotes: 1
Views: 1504
Reputation: 1594
Maybe creating a virtual will help solve this. I'm not really sure what you are trying to do.
You can create a virtual path on your website that is mapped to another physical path on your machine (i.e another website)
How To Create a Virtual Directory in Internet Information Services (IIS)
Then when you use MapPath to access this virtual you can access another website.
Update:
@me: You can do to IIS and create a virtual directory to access the other application. From your first application you would create an 'Application2' virtual and point it to C:\inetpub\wwwroot\website2.
Now when you access http://www.mywebsite.com/Application2 you are looking at files in the other application (C:\inetpub\wwwroot\website2).
Also, a Server.MapPath("./Application2") will return the path in C:\inetpub\wwwroot\website2\
I hope that helps.
Upvotes: 4
Reputation: 700720
The Server.MapPath
method is used to get the physical path of an url. It has nothing to do with creating an URL to a file. Even if you can reach the physical files of one web site from the server code of another, that doesn't mean that you can specify an url to do that.
You can't create a relative path from one domain to another. Even if they happen to be on the same server, there is still no common parent for the domains that you can use to make a relative path from one to another.
Each domain name just points to an IP address where you reach the server that handles the request, and there is no relation between domain names at all. Even if two domain names points to the same IP address, that doesn't mean that they need to be on the same server, and if two domain names point to different IP addresses they can still be handled by the same server.
Upvotes: 0
Reputation: 191037
Why don't you just explicitly spell out the absolute Url?
Upvotes: 0