Paths in Subdomains

  • Thread starter Muhammad Ahsin Saleem
  • Start date
M

Muhammad Ahsin Saleem

Hi Everybody,

I have my site xyz.com.pk hosted on a domain, also there is another
subdomain hosted as admin.xyz.com.pk.

I have a form in the admin subdomain that wants to save a file in the
xyz.com.pk subdomain. I am having a problem with the path of file. I
have used the following code

Dim filename As String =
Server.MapPath("../xyz.com.pk/myfolder/myfile.xml")

but it gives the following exception

An Exception has Occured.System.Web.HttpException: Cannot use a leading
... to exit above the top directory. at
System.Web.Util.UrlPath.ReduceVirtualPath(String path) at
System.Web.Util.UrlPath.Reduce(String path) at
System.Web.Util.UrlPath.Combine(String appPath, String basepath, String
relative) at System.Web.VirtualPath.Combine(VirtualPath relativePath)
at System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath
baseVirtualDir, Boolean allowCrossAppMapping) at
System.Web.HttpServerUtility.MapPath(String path)


Can anybody help me to solve this problem.

I need an urgant response

Thanx in advance.
 
A

Aidy

I have a form in the admin subdomain that wants to save a file in the
xyz.com.pk subdomain. I am having a problem with the path of file. I
have used the following code

Are the two sites on the same server? You might not be able to use MapPath
as the target site is outwith your site's control. Rather than MapPath you
could try using a hard-coded path;

c:\inetpub\yoursite\page.aspx
 
M

Muhammad Ahsin Saleem

Are the two sites on the same server? You might not be able to use MapPath
as the target site is outwith your site's control. Rather than MapPath you
could try using a hard-coded path;

c:\inetpub\yoursite\page.aspx

Yes Both sites are on the same server. You have told me to use
hardcoded path well how can i get this hardcoded path as i Have hosted
them on a server. Site are not on local machine. Is there any command
in Visual studio that will tell me this Path or should i contact my
server to get this full hardcoded path.
 
A

Aidy

should i contact my
server to get this full hardcoded path.

Ask whoever hosts your site if you can get the path. They may need to set
up permissions to allow one of your sites to write to the other's file space
though.
 
G

gerry

MapPath is used to map a virtual server path to a physical path. ("/../xyz")
is not a virtual path.

Assuming that your 2 web site directories are physical siblings, you could
use

Dim appPath As String = Server.MapPath("/")
Dim filePath As String = appPath+"/../xyz.com.pk/myfolder/myfile.xml"
Dim filename As String = System.IO.FullPath(filePath)

appPath=c:\inetpub\wwroot\admin.xyz.com.pk
filePath=c:\inetpub\wwroot\admin.xyz.com.pk/../xyz.com.pk/myfolder/myfile.xml
filename=c:\inetpub\wwroot\xyz.com.pk\myfolder\myfile.xml


Gerry
 
P

Patrice

Using .. in Server.MapPath is an option that can be disabled in IIS for
safety reasons. Try an aboslute path...

Patrice
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,068
Latest member
MakersCBDIngredients

Latest Threads

Top