473,385 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Paths in Subdomains

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.

Jan 15 '07 #1
7 2345
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
Jan 15 '07 #2
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.

Jan 15 '07 #3
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.
Jan 15 '07 #4
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\myf ile.xml
Gerry


"Muhammad Ahsin Saleem" <ah**********@gmail.comwrote in message
news:11**********************@11g2000cwr.googlegro ups.com...
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.

Jan 15 '07 #5
setup a web method within the main site to allow access to the specific file

"Muhammad Ahsin Saleem" <ah**********@gmail.comwrote in message
news:11*********************@v45g2000cwv.googlegro ups.com...
>
>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.

Jan 15 '07 #6
sorry that should have been : ("../xyz") is not a virtual path.

"gerry" <ge**@canada.comwrote in message
news:uh**************@TK2MSFTNGP02.phx.gbl...
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\myf ile.xml
Gerry


"Muhammad Ahsin Saleem" <ah**********@gmail.comwrote in message
news:11**********************@11g2000cwr.googlegro ups.com...
>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(Strin g 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.


Jan 15 '07 #7
Using .. in Server.MapPath is an option that can be disabled in IIS for
safety reasons. Try an aboslute path...

Patrice

"Muhammad Ahsin Saleem" <ah**********@gmail.coma écrit dans le message de
news: 11**********************@11g2000cwr.googlegroups.c om...
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.

Jan 15 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: seo | last post by:
Hi all, I have a site called www.Mydomain.com. I would like to offer free hoting to the people and offer a site with their username like this. www.Mydomain.com/user. I want user can upload...
1
by: steve | last post by:
Hi I am writing an application which ideally requires the creation of subdomains dynamically via asp. However I want all the subdomains to point to 1 asp file, which I wish to use to figure out...
3
by: craigkenisston | last post by:
In an application I'm developing I will be using subdomains in the main website to hold some sections of the sites. There will be many serverside generated links that will point to this...
2
by: craigkenisston | last post by:
Hi, I create a one day ticket in my authentication code like this : private void btnLogin_Click(object sender, System.EventArgs e) { string _userId = txtUserId.Text; string _password =...
4
by: radiax | last post by:
Is there a way to associate or bind a subdomain to a tcp sockets under .net framework (vb.net / c#). I know ip address can be used when using sockets, but the problem is the ip address is shared...
1
by: Hans Kesting | last post by:
Hi, Is it possible to share sessions between subdomains? Say: the user logs in at www.company.com, and is redirected to my.company.com. This is a different url for the same application. Can I...
8
by: Kenny Lai | last post by:
hey, Is there a way to communicate between iframes on different subdomains? e.g. from one.dot.com to two.dot.com? there is a security access restriction passing javascript commands between...
9
by: Josh | last post by:
I run a Joomla website and am familiar with php in some but not all aspects. Currently I am trying to find some solutions related to session handling. Am I correct in saying that "login" is kept...
3
by: Jonathan Wood | last post by:
Perhaps someone who understand Web hosting can offer some insight into this. I have several sites hosted at http://www.crystaltech.com. There were highly recommended and seem pretty good. But...
3
by: akadeco | last post by:
Hi Could anyone give me some pointers on how to remove subdomains from a string? For example: If the string was bytes.com, it would stay bytes.com If it was subdomain.bytes.com, it would...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.