Showing posts with label virtual. Show all posts
Showing posts with label virtual. Show all posts

Saturday, March 24, 2012

server.execute and virtual paths

I'm trying to execute an aspx page by calling Server.Execute.
The aspx page I'm trying to execute is in a different web app from the aspx
page containing the Server.Execute statement. A slightly clearer explanation
..
Page1 exists in WebApp1. In the code-behind of Page2 in WebApp2, I have put
Server.Execute("Path to Page1 in WebApp1").
When I call Server.Execute(String) using "http://localhost/WebApp1/Page1.asp
x", everything works ok and Page1 pops up in a new window.
But when I try to use the same path with the overloaded version, Server.Exec
ute(String, TextWriter), I get an error saying I must pass in a virtual path
. So I pass in "../WebApp1/Page1.aspx" as the path. But now I get this error
:
The virtual path '/WebApp1/Page1.aspx.cs' maps to another application, which
is not allowed.
But I can execute the same page using Server.Execute(String) and "http://...
"!!
So, is my virtual path wrong? Or is it something else?
(I need to use the overloaded version Server.Execute(String, TextWriter) so
that I can capture the output from Page1 and NOT have it popup in a new wind
ow.)Hmmm, sorry peoples...
Forget my first post...it seems my dlls weren't recompiling correctly and Se
rver.Execute(String) plus "http://..." seemed to work cos it was using some
old code but in fact that doesn't work.
So, it seems I can't use Server.Execute to execute pages in another web app.
Is there another way to accomplish this?
Cheers, Dune
"Dune" wrote:

> I'm trying to execute an aspx page by calling Server.Execute.
> The aspx page I'm trying to execute is in a different web app from the asp
x page containing the Server.Execute statement. A slightly clearer explanati
on...
> Page1 exists in WebApp1. In the code-behind of Page2 in WebApp2, I have pu
t Server.Execute("Path to Page1 in WebApp1").
> When I call Server.Execute(String) using "http://localhost/WebApp1/Page1.a
spx", everything works ok and Page1 pops up in a new window.
> But when I try to use the same path with the overloaded version, Server.Ex
ecute(String, TextWriter), I get an error saying I must pass in a virtual pa
th. So I pass in "../WebApp1/Page1.aspx" as the path. But now I get this err
or:
> The virtual path '/WebApp1/Page1.aspx.cs' maps to another application, whi
ch is not allowed.
> But I can execute the same page using Server.Execute(String) and "http://.
."!!
> So, is my virtual path wrong? Or is it something else?
> (I need to use the overloaded version Server.Execute(String, TextWriter) s
o that I can capture the output from Page1 and NOT have it popup in a new wi
ndow.)
>
You're going to be stuck with Response.Redirect, I think.
Dale Preston
MCAD, MCSE, MCDBA
"Dune" <Dune@.discussions.microsoft.com> wrote in message
news:0B7B2BBD-9D95-4ACC-B5E4-8EF63726EE86@.microsoft.com...
> Hmmm, sorry peoples...
> Forget my first post...it seems my dlls weren't recompiling correctly and
Server.Execute(String) plus "http://..." seemed to work cos it was using
some old code but in fact that doesn't work.
> So, it seems I can't use Server.Execute to execute pages in another web
app.
> Is there another way to accomplish this?
> Cheers, Dune
> "Dune" wrote:
>
aspx page containing the Server.Execute statement. A slightly clearer
explanation...
put Server.Execute("Path to Page1 in WebApp1").
"http://localhost/WebApp1/Page1.aspx", everything works ok and Page1 pops up
in a new window.
Server.Execute(String, TextWriter), I get an error saying I must pass in a
virtual path. So I pass in "../WebApp1/Page1.aspx" as the path. But now I
get this error:
which is not allowed.
"http://..."!!
so that I can capture the output from Page1 and NOT have it popup in a new
window.)

server.execute and virtual paths

I'm trying to execute an aspx page by calling Server.Execute.

The aspx page I'm trying to execute is in a different web app from the aspx page containing the Server.Execute statement. A slightly clearer explanation...

Page1 exists in WebApp1. In the code-behind of Page2 in WebApp2, I have put Server.Execute("Path to Page1 in WebApp1").

When I call Server.Execute(String) using "http://localhost/WebApp1/Page1.aspx", everything works ok and Page1 pops up in a new window.

But when I try to use the same path with the overloaded version, Server.Execute(String, TextWriter), I get an error saying I must pass in a virtual path. So I pass in "../WebApp1/Page1.aspx" as the path. But now I get this error:

The virtual path '/WebApp1/Page1.aspx.cs' maps to another application, which is not allowed.

But I can execute the same page using Server.Execute(String) and "http://..."!!

So, is my virtual path wrong? Or is it something else?
(I need to use the overloaded version Server.Execute(String, TextWriter) so that I can capture the output from Page1 and NOT have it popup in a new window.)Hmmm, sorry peoples...

Forget my first post...it seems my dlls weren't recompiling correctly and Server.Execute(String) plus "http://..." seemed to work cos it was using some old code but in fact that doesn't work.

So, it seems I can't use Server.Execute to execute pages in another web app.
Is there another way to accomplish this?

Cheers, Dune

"Dune" wrote:

> I'm trying to execute an aspx page by calling Server.Execute.
> The aspx page I'm trying to execute is in a different web app from the aspx page containing the Server.Execute statement. A slightly clearer explanation...
> Page1 exists in WebApp1. In the code-behind of Page2 in WebApp2, I have put Server.Execute("Path to Page1 in WebApp1").
> When I call Server.Execute(String) using "http://localhost/WebApp1/Page1.aspx", everything works ok and Page1 pops up in a new window.
> But when I try to use the same path with the overloaded version, Server.Execute(String, TextWriter), I get an error saying I must pass in a virtual path. So I pass in "../WebApp1/Page1.aspx" as the path. But now I get this error:
> The virtual path '/WebApp1/Page1.aspx.cs' maps to another application, which is not allowed.
> But I can execute the same page using Server.Execute(String) and "http://..."!!
> So, is my virtual path wrong? Or is it something else?
> (I need to use the overloaded version Server.Execute(String, TextWriter) so that I can capture the output from Page1 and NOT have it popup in a new window.)
You're going to be stuck with Response.Redirect, I think.

Dale Preston
MCAD, MCSE, MCDBA

"Dune" <Dune@.discussions.microsoft.com> wrote in message
news:0B7B2BBD-9D95-4ACC-B5E4-8EF63726EE86@.microsoft.com...
> Hmmm, sorry peoples...
> Forget my first post...it seems my dlls weren't recompiling correctly and
Server.Execute(String) plus "http://..." seemed to work cos it was using
some old code but in fact that doesn't work.
> So, it seems I can't use Server.Execute to execute pages in another web
app.
> Is there another way to accomplish this?
> Cheers, Dune
> "Dune" wrote:
> > I'm trying to execute an aspx page by calling Server.Execute.
> > The aspx page I'm trying to execute is in a different web app from the
aspx page containing the Server.Execute statement. A slightly clearer
explanation...
> > Page1 exists in WebApp1. In the code-behind of Page2 in WebApp2, I have
put Server.Execute("Path to Page1 in WebApp1").
> > When I call Server.Execute(String) using
"http://localhost/WebApp1/Page1.aspx", everything works ok and Page1 pops up
in a new window.
> > But when I try to use the same path with the overloaded version,
Server.Execute(String, TextWriter), I get an error saying I must pass in a
virtual path. So I pass in "../WebApp1/Page1.aspx" as the path. But now I
get this error:
> > The virtual path '/WebApp1/Page1.aspx.cs' maps to another application,
which is not allowed.
> > But I can execute the same page using Server.Execute(String) and
"http://..."!!
> > So, is my virtual path wrong? Or is it something else?
> > (I need to use the overloaded version Server.Execute(String, TextWriter)
so that I can capture the output from Page1 and NOT have it popup in a new
window.)

Tuesday, March 13, 2012

Server.MapPath & Request.MapPath

Server.MapPath returns the physical file path that corresponds to the
specified virtual path whereas Request.MapPath maps the specified
virtual path to a physical path. Assuming that a file named Hello.aspx
resides in C:\Inetpub\wwwroot\MyFolder, the output of both

Response.Write(Server.MapPath("Hello.aspx"))

&

Response.Write(Request.MapPath("Hello.aspx"))

is C:\Inetpub\wwwroot\MyFolder\Hello.aspx. So what's the difference
between Server.MapPath & Request.MapPath?

ThanksHello rn5a@.rediffmail.com,

There are no difference in this aspect, because the Server.MapPath calls the
_context.Request.MapPath(path)
inside its method

--
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

Quote:

Originally Posted by

Server.MapPath returns the physical file path that corresponds to the
specified virtual path whereas Request.MapPath maps the specified
virtual path to a physical path. Assuming that a file named Hello.aspx
resides in C:\Inetpub\wwwroot\MyFolder, the output of both
>
Response.Write(Server.MapPath("Hello.aspx"))
>
&
>
Response.Write(Request.MapPath("Hello.aspx"))
>
is C:\Inetpub\wwwroot\MyFolder\Hello.aspx. So what's the difference
between Server.MapPath & Request.MapPath?
>
Thanks
>


The way I look at it, there's a single MapPath method
which is called in different contexts with different parameters.

public virtual string MapPath(string virtualPath)
{
return null;
}

public string MapPath(string virtualPath)
{
return this.MapPath(VirtualPath.CreateAllowNull(virtualPa th));
}

internal string MapPath(VirtualPath virtualPath)
{
if (this._wr != null)
{
return this.MapPath(virtualPath, this.FilePathObject, true);
}
return virtualPath.MapPath();
}

public string MapPath(string virtualPath, string baseVirtualDir, bool allowCrossAppMapping)
{
VirtualPath filePathObject;
if (string.IsNullOrEmpty(baseVirtualDir))
{
filePathObject = this.FilePathObject;
}
else
{
filePathObject = VirtualPath.CreateTrailingSlash(baseVirtualDir);
}
return this.MapPath(VirtualPath.CreateAllowNull(virtualPa th), filePathObject, allowCrossAppMapping);
}

internal string MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, bool allowCrossAppMapping)
{
if (this._wr == null)
{
throw new HttpException(SR.GetString("Cannot_map_path_without_context"));
}
if (virtualPath == null)
{
virtualPath = VirtualPath.Create(".");
}
VirtualPath path = virtualPath;
if (baseVirtualDir != null)
{
virtualPath = baseVirtualDir.Combine(virtualPath);
}
if (!allowCrossAppMapping)
{
virtualPath.FailIfNotWithinAppRoot();
}
string str = virtualPath.MapPathInternal();
if (((virtualPath.VirtualPathString == "/") && (path.VirtualPathString != "/"))
&& (!path.HasTrailingSlash && UrlPath.PathEndsWithExtraSlash(str)))
{
str = str.Substring(0, str.Length - 1);
}
InternalSecurityPermissions.PathDiscovery(str).Dem and();
return str;
}

public string MapPath(string path)
{
if (this._context == null)
{
throw new HttpException(SR.GetString("Server_not_available"));
}
return this._context.Request.MapPath(path);
}

public string MapPath()
{
return HostingEnvironment.MapPath(this);
}

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espanol : http://asp.net.do/foros/
======================================
"Michael Nemtsev" <nemtsev@.msn.comwrote in message news:3d9fba1aec828c9d64fc67e45f0@.msnews.microsoft. com...

Quote:

Originally Posted by

Hello rn5a@.rediffmail.com,
>
There are no difference in this aspect, because the Server.MapPath calls the _context.Request.MapPath(path)
inside its method
>
--
WBR, Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we miss it, but that it is too low and we
reach it" (c) Michelangelo
>

Quote:

Originally Posted by

>Server.MapPath returns the physical file path that corresponds to the
>specified virtual path whereas Request.MapPath maps the specified
>virtual path to a physical path. Assuming that a file named Hello.aspx
>resides in C:\Inetpub\wwwroot\MyFolder, the output of both
>>
>Response.Write(Server.MapPath("Hello.aspx"))
>>
>&
>>
>Response.Write(Request.MapPath("Hello.aspx"))
>>
>is C:\Inetpub\wwwroot\MyFolder\Hello.aspx. So what's the difference
>between Server.MapPath & Request.MapPath?
>>
>Thanks
>>


>
>


On Oct 6, 6:45 am, "Juan T. Llibre" <nomailrepl...@.nowhere.comwrote:

Quote:

Originally Posted by

The way I look at it, there's a single MapPath method
which is called in different contexts with different parameters.
>
public virtual string MapPath(string virtualPath)
{
return null;
>
}
>
public string MapPath(string virtualPath)
{
return this.MapPath(VirtualPath.CreateAllowNull(virtualPa th));
>
}
>
internal string MapPath(VirtualPath virtualPath)
{
if (this._wr != null)
{
return this.MapPath(virtualPath, this.FilePathObject, true);
}
return virtualPath.MapPath();
>
}
>
public string MapPath(string virtualPath, string baseVirtualDir, bool allowCrossAppMapping)
{
VirtualPath filePathObject;
if (string.IsNullOrEmpty(baseVirtualDir))
{
filePathObject = this.FilePathObject;
}
else
{
filePathObject = VirtualPath.CreateTrailingSlash(baseVirtualDir);
}
return this.MapPath(VirtualPath.CreateAllowNull(virtualPa th), filePathObject, allowCrossAppMapping);
>
}
>
internal string MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, bool allowCrossAppMapping)
{
if (this._wr == null)
{
throw new HttpException(SR.GetString("Cannot_map_path_without_context"));
}
if (virtualPath == null)
{
virtualPath = VirtualPath.Create(".");
}
VirtualPath path = virtualPath;
if (baseVirtualDir != null)
{
virtualPath = baseVirtualDir.Combine(virtualPath);
}
if (!allowCrossAppMapping)
{
virtualPath.FailIfNotWithinAppRoot();
}
string str = virtualPath.MapPathInternal();
if (((virtualPath.VirtualPathString == "/") && (path.VirtualPathString != "/"))
&& (!path.HasTrailingSlash && UrlPath.PathEndsWithExtraSlash(str)))
{
str = str.Substring(0, str.Length - 1);
}
InternalSecurityPermissions.PathDiscovery(str).Dem and();
return str;
>
}
>
public string MapPath(string path)
{
if (this._context == null)
{
throw new HttpException(SR.GetString("Server_not_available"));
}
return this._context.Request.MapPath(path);
>
}
>
public string MapPath()
{
return HostingEnvironment.MapPath(this);
>
}
>
Juan T. Llibre, asp.net MVP
asp.net faq :http://asp.net.do/faq/
foros de asp.net, en espanol :http://asp.net.do/foros/
======================================
>
>
>
"Michael Nemtsev" <nemt...@.msn.comwrote in messagenews:3d9fba1aec828c9d64fc67e45f0@.msnews.mic rosoft.com...

Quote:

Originally Posted by

Hello r...@.rediffmail.com,


>

Quote:

Originally Posted by

There are no difference in this aspect, because the Server.MapPath calls the _context.Request.MapPath(path)
inside its method


>

Quote:

Originally Posted by

--
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we miss it, but that it is too low and we
reach it" (c) Michelangelo


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Server.MapPath returns the physical file path that corresponds to the
specified virtual path whereas Request.MapPath maps the specified
virtual path to a physical path. Assuming that a file named Hello.aspx
resides in C:\Inetpub\wwwroot\MyFolder, the output of both


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Response.Write(Server.MapPath("Hello.aspx"))


>

Quote:

Originally Posted by

Quote:

Originally Posted by

&


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Response.Write(Request.MapPath("Hello.aspx"))


>

Quote:

Originally Posted by

Quote:

Originally Posted by

is C:\Inetpub\wwwroot\MyFolder\Hello.aspx. So what's the difference
between Server.MapPath & Request.MapPath?


>

Quote:

Originally Posted by

Quote:

Originally Posted by

Thanks- Hide quoted text -


>
- Show quoted text -


Thanks both of you for your inputs but Juan, being a ASP.NET newbie,
your response has left me in a tizzy! More so because I use VB.NET &
not C# & all the C# code you have cited has left me further confused!

BTW, I have come across the word "context" numerous times since I have
started learning ASP.NET but to be honest, I don't understand what
does it exactly mean. Can someone please explain me what does
"context" mean with respect to .NET? As such, I know what does
"context" mean in English!

If giving examples, please try using VB & not C#.

Ron

server.mappath and network shares

My IIS Web site has a virtual directory called content mapped to a network
share. If the home directory of the Web site is c:\inetpub\wwwroot and the
virtual directory maps to the network share \\myserver\content,
Server.MapPath is returning c:\inetpub\wwwroot\content rather than
\\myserver\content.

I've tried adding
<identity impersonate="true" userName="name" password="password"/
to the web.config file in order to make sure the identity of the account
accessing network resources has appropriate rights, but that doesn't change
the path returned by MapPath.

Does anyone know what's wrong?Hi Jay,

I'm viewing the thread and found that it is a duplicated one with another
post(has the same title) in this newsgroup. I've posted a reply and
provided some of my test results in that thread. Would you please have a
check there. Also, if you have any questoins, please feel free to post in
either ones. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

server.mappath and network shares

My IIS Web site has a virtual directory called content mapped to a network
share. If the home directory of the Web site is c:\inetpub\wwwroot and the
virtual directory maps to the network share \\myserver\content,
Server.MapPath is returning c:\inetpub\wwwroot\content rather than
\\myserver\content.

I've tried adding
<identity impersonate="true" userName="name" password="password"/
to the web.config file in order to make sure the identity of the account
accessing network resources has appropriate rights, but that doesn't change
the path returned by MapPath.

Does anyone know what's wrong?That is because Server.MapPath doesn't know anything about IIS's MetaData and where that actual path is located. Either you're going to have to hard code it in as a UNC path, or create some utility that will read the MetaData of IIS to get the actual physical location.

Matt Hawley, MCAD .NET
http://www.eworldui.net

My IIS Web site has a virtual directory called content mapped to a network
share. If the home directory of the Web site is c:\inetpub\wwwroot and the
virtual directory maps to the network share \\myserver\content,
Server.MapPath is returning c:\inetpub\wwwroot\content rather than
\\myserver\content.

I've tried adding
<identity impersonate="true" userName="name" password="password"/
to the web.config file in order to make sure the identity of the account
accessing network resources has appropriate rights, but that doesn't change
the path returned by MapPath.

Does anyone know what's wrong?
That is because Server.MapPath doesn't know anything about IIS's MetaData and where that actual path is located. Either you're going to have to hard code it in as a UNC path, or create some utility that will read the MetaData of IIS to get the actual physical location.

Matt Hawley, MCAD .NET
http://www.eworldui.net

My IIS Web site has a virtual directory called content mapped to a network
share. If the home directory of the Web site is c:\inetpub\wwwroot and the
virtual directory maps to the network share \\myserver\content,
Server.MapPath is returning c:\inetpub\wwwroot\content rather than
\\myserver\content.

I've tried adding
<identity impersonate="true" userName="name" password="password"/
to the web.config file in order to make sure the identity of the account
accessing network resources has appropriate rights, but that doesn't change
the path returned by MapPath.

Does anyone know what's wrong?
But converting a virtual path to a physical path is exactly what mappath
should do. It certainly does it for local files, and that requires reading
metadata.

I've seen other posts on the group that indicate it does work the way I want
it to for some people.

-Jay

"Matt Hawley" <mhawley@.n!o!s!p!a!m.integrityts.com> wrote in message
news:OGFAk6%23GEHA.3068@.TK2MSFTNGP11.phx.gbl...
> That is because Server.MapPath doesn't know anything about IIS's MetaData
and where that actual path is located. Either you're going to have to hard
code it in as a UNC path, or create some utility that will read the MetaData
of IIS to get the actual physical location.
> Matt Hawley, MCAD .NET
> http://www.eworldui.net
> My IIS Web site has a virtual directory called content mapped to a
network
> share. If the home directory of the Web site is c:\inetpub\wwwroot and
the
> virtual directory maps to the network share \\myserver\content,
> Server.MapPath is returning c:\inetpub\wwwroot\content rather than
> \\myserver\content.
> I've tried adding
> <identity impersonate="true" userName="name" password="password"/>
> to the web.config file in order to make sure the identity of the account
> accessing network resources has appropriate rights, but that doesn't
change
> the path returned by MapPath.
> Does anyone know what's wrong?
>
But converting a virtual path to a physical path is exactly what mappath
should do. It certainly does it for local files, and that requires reading
metadata.

I've seen other posts on the group that indicate it does work the way I want
it to for some people.

-Jay

"Matt Hawley" <mhawley@.n!o!s!p!a!m.integrityts.com> wrote in message
news:OGFAk6%23GEHA.3068@.TK2MSFTNGP11.phx.gbl...
> That is because Server.MapPath doesn't know anything about IIS's MetaData
and where that actual path is located. Either you're going to have to hard
code it in as a UNC path, or create some utility that will read the MetaData
of IIS to get the actual physical location.
> Matt Hawley, MCAD .NET
> http://www.eworldui.net
> My IIS Web site has a virtual directory called content mapped to a
network
> share. If the home directory of the Web site is c:\inetpub\wwwroot and
the
> virtual directory maps to the network share \\myserver\content,
> Server.MapPath is returning c:\inetpub\wwwroot\content rather than
> \\myserver\content.
> I've tried adding
> <identity impersonate="true" userName="name" password="password"/>
> to the web.config file in order to make sure the identity of the account
> accessing network resources has appropriate rights, but that doesn't
change
> the path returned by MapPath.
> Does anyone know what's wrong?
>
Hi Jay,

Thanks for your followup. Regarding on this issue, I've done a general test
on my side and found the Server.MapPath did return the UNCPath of the
remote server(where the asp.net files and assemlby actually locate). Here
are the detailed enviroment infos on my test:
1. Remote shared Machine: Win2k server with .net framework1.1 installed
shared one folder as the root folder of a certain web application.

2. Server Host Machine(where host the webapplication in IIS): WinXP
Professional with .net framework1.1 installed. And the two machines are in
the same domain so When creating the virutal directory on the XP box, I
paste the certain UNC path (\\servername\sharedfoldername) and then select
a DomainAccount which are administrator on both machine. Then, when I visit
the page in the web application and the page has the following code in
Page_Load:
Response.Write("<br>" + Server.MapPath("."));

Then, the output display the certain UNC path on the WIN2K
mathine((\\servername\sharedfoldername) rather than the physical path on
the WINXP BOX. I've also tried the contrary( share a folder on the XP box
and host the IIS Virutal Directory on the WIN2K machine, still use the
DomainAccount when accessing the UNC folder
in IIS manager).

So I think you may have a check on the above steps I listed to see whether
they can provide any clues. Also, I recommend that you also perform such a
test on your side to see whether it works. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Jay,

Thanks for your followup. Regarding on this issue, I've done a general test
on my side and found the Server.MapPath did return the UNCPath of the
remote server(where the asp.net files and assemlby actually locate). Here
are the detailed enviroment infos on my test:
1. Remote shared Machine: Win2k server with .net framework1.1 installed
shared one folder as the root folder of a certain web application.

2. Server Host Machine(where host the webapplication in IIS): WinXP
Professional with .net framework1.1 installed. And the two machines are in
the same domain so When creating the virutal directory on the XP box, I
paste the certain UNC path (\\servername\sharedfoldername) and then select
a DomainAccount which are administrator on both machine. Then, when I visit
the page in the web application and the page has the following code in
Page_Load:
Response.Write("<br>" + Server.MapPath("."));

Then, the output display the certain UNC path on the WIN2K
mathine((\\servername\sharedfoldername) rather than the physical path on
the WINXP BOX. I've also tried the contrary( share a folder on the XP box
and host the IIS Virutal Directory on the WIN2K machine, still use the
DomainAccount when accessing the UNC folder
in IIS manager).

So I think you may have a check on the above steps I listed to see whether
they can provide any clues. Also, I recommend that you also perform such a
test on your side to see whether it works. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Steven-

Rather than have the whole site located on a share from a remote machine,
can you create a Web site locally, then create a virtual directory under the
site that points to a remote machine share?

-Jay

"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> wrote in message
news:vnIAo%23UHEHA.3444@.cpmsftngxa06.phx.gbl...
> Hi Jay,
> Thanks for your followup. Regarding on this issue, I've done a general
test
> on my side and found the Server.MapPath did return the UNCPath of the
> remote server(where the asp.net files and assemlby actually locate). Here
> are the detailed enviroment infos on my test:
> 1. Remote shared Machine: Win2k server with .net framework1.1 installed
> shared one folder as the root folder of a certain web application.
> 2. Server Host Machine(where host the webapplication in IIS): WinXP
> Professional with .net framework1.1 installed. And the two machines are
in
> the same domain so When creating the virutal directory on the XP box, I
> paste the certain UNC path (\\servername\sharedfoldername) and then select
> a DomainAccount which are administrator on both machine. Then, when I
visit
> the page in the web application and the page has the following code in
> Page_Load:
> Response.Write("<br>" + Server.MapPath("."));
> Then, the output display the certain UNC path on the WIN2K
> mathine((\\servername\sharedfoldername) rather than the physical path on
> the WINXP BOX. I've also tried the contrary( share a folder on the XP box
> and host the IIS Virutal Directory on the WIN2K machine, still use the
> DomainAccount when accessing the UNC folder
> in IIS manager).
> So I think you may have a check on the above steps I listed to see whether
> they can provide any clues. Also, I recommend that you also perform such a
> test on your side to see whether it works. Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
>
Steven-

Rather than have the whole site located on a share from a remote machine,
can you create a Web site locally, then create a virtual directory under the
site that points to a remote machine share?

-Jay

"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> wrote in message
news:vnIAo%23UHEHA.3444@.cpmsftngxa06.phx.gbl...
> Hi Jay,
> Thanks for your followup. Regarding on this issue, I've done a general
test
> on my side and found the Server.MapPath did return the UNCPath of the
> remote server(where the asp.net files and assemlby actually locate). Here
> are the detailed enviroment infos on my test:
> 1. Remote shared Machine: Win2k server with .net framework1.1 installed
> shared one folder as the root folder of a certain web application.
> 2. Server Host Machine(where host the webapplication in IIS): WinXP
> Professional with .net framework1.1 installed. And the two machines are
in
> the same domain so When creating the virutal directory on the XP box, I
> paste the certain UNC path (\\servername\sharedfoldername) and then select
> a DomainAccount which are administrator on both machine. Then, when I
visit
> the page in the web application and the page has the following code in
> Page_Load:
> Response.Write("<br>" + Server.MapPath("."));
> Then, the output display the certain UNC path on the WIN2K
> mathine((\\servername\sharedfoldername) rather than the physical path on
> the WINXP BOX. I've also tried the contrary( share a folder on the XP box
> and host the IIS Virutal Directory on the WIN2K machine, still use the
> DomainAccount when accessing the UNC folder
> in IIS manager).
> So I think you may have a check on the above steps I listed to see whether
> they can provide any clues. Also, I recommend that you also perform such a
> test on your side to see whether it works. Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
>
Hi Jay,

In fact, my test is just Virutal Directory based rather than site based. I
just create a Virutal Directory under the local IIS's default site and set
its "Network Directory" path as a UNC path on another remote machine.
However, I think the key point should be the "Connect As.." account , I
used a PowerFull Domain account which has the administrator permission on
the remote machine. So I think we may have a further check on the
security. Do you think so? Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Jay,

In fact, my test is just Virutal Directory based rather than site based. I
just create a Virutal Directory under the local IIS's default site and set
its "Network Directory" path as a UNC path on another remote machine.
However, I think the key point should be the "Connect As.." account , I
used a PowerFull Domain account which has the administrator permission on
the remote machine. So I think we may have a further check on the
security. Do you think so? Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Jay,

Have you got any further ideas on this issue? If you have anything unclear
or if there're anything else we can help, please feel free to post here.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

server.mappath and network shares

My IIS Web site has a virtual directory called content mapped to a network
share. If the home directory of the Web site is c:\inetpub\wwwroot and the
virtual directory maps to the network share \\myserver\content,
Server.MapPath is returning c:\inetpub\wwwroot\content rather than
\\myserver\content.

I've tried adding
<identity impersonate="true" userName="name" password="password"/
to the web.config file in order to make sure the identity of the account
accessing network resources has appropriate rights, but that doesn't change
the path returned by MapPath.

Does anyone know what's wrong?Hi Jay,

I'm viewing the thread and found that it is a duplicated one with another
post(has the same title) in this newsgroup. I've posted a reply and
provided some of my test results in that thread. Would you please have a
check there. Also, if you have any questoins, please feel free to post in
either ones. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Jay,

I'm viewing the thread and found that it is a duplicated one with another
post(has the same title) in this newsgroup. I've posted a reply and
provided some of my test results in that thread. Would you please have a
check there. Also, if you have any questoins, please feel free to post in
either ones. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

server.mappath and network shares

My IIS Web site has a virtual directory called content mapped to a network
share. If the home directory of the Web site is c:\inetpub\wwwroot and the
virtual directory maps to the network share \\myserver\content,
Server.MapPath is returning c:\inetpub\wwwroot\content rather than
\\myserver\content.

I've tried adding
<identity impersonate="true" userName="name" password="password"/
to the web.config file in order to make sure the identity of the account
accessing network resources has appropriate rights, but that doesn't change
the path returned by MapPath.

Does anyone know what's wrong?Hi Jay,

I'm viewing the thread and found that it is a duplicated one with another
post(has the same title) in this newsgroup. I've posted a reply and
provided some of my test results in that thread. Would you please have a
check there. Also, if you have any questoins, please feel free to post in
either ones. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

server.mappath and network shares

My IIS Web site has a virtual directory called content mapped to a network
share. If the home directory of the Web site is c:\inetpub\wwwroot and the
virtual directory maps to the network share \\myserver\content,
Server.MapPath is returning c:\inetpub\wwwroot\content rather than
\\myserver\content.

I've tried adding
<identity impersonate="true" userName="name" password="password"/
to the web.config file in order to make sure the identity of the account
accessing network resources has appropriate rights, but that doesn't change
the path returned by MapPath.

Does anyone know what's wrong?That is because Server.MapPath doesn't know anything about IIS's MetaData and where that actual path is located. Either you're going to have to hard code it in as a UNC path, or create some utility that will read the MetaData of IIS to get the actual physical location.

Matt Hawley, MCAD .NET
http://www.eworldui.net

My IIS Web site has a virtual directory called content mapped to a network
share. If the home directory of the Web site is c:\inetpub\wwwroot and the
virtual directory maps to the network share \\myserver\content,
Server.MapPath is returning c:\inetpub\wwwroot\content rather than
\\myserver\content.

I've tried adding
<identity impersonate="true" userName="name" password="password"/
to the web.config file in order to make sure the identity of the account
accessing network resources has appropriate rights, but that doesn't change
the path returned by MapPath.

Does anyone know what's wrong?
But converting a virtual path to a physical path is exactly what mappath
should do. It certainly does it for local files, and that requires reading
metadata.

I've seen other posts on the group that indicate it does work the way I want
it to for some people.

-Jay

"Matt Hawley" <mhawley@.n!o!s!p!a!m.integrityts.com> wrote in message
news:OGFAk6%23GEHA.3068@.TK2MSFTNGP11.phx.gbl...
> That is because Server.MapPath doesn't know anything about IIS's MetaData
and where that actual path is located. Either you're going to have to hard
code it in as a UNC path, or create some utility that will read the MetaData
of IIS to get the actual physical location.
> Matt Hawley, MCAD .NET
> http://www.eworldui.net
> My IIS Web site has a virtual directory called content mapped to a
network
> share. If the home directory of the Web site is c:\inetpub\wwwroot and
the
> virtual directory maps to the network share \\myserver\content,
> Server.MapPath is returning c:\inetpub\wwwroot\content rather than
> \\myserver\content.
> I've tried adding
> <identity impersonate="true" userName="name" password="password"/>
> to the web.config file in order to make sure the identity of the account
> accessing network resources has appropriate rights, but that doesn't
change
> the path returned by MapPath.
> Does anyone know what's wrong?
>
Hi Jay,

Thanks for your followup. Regarding on this issue, I've done a general test
on my side and found the Server.MapPath did return the UNCPath of the
remote server(where the asp.net files and assemlby actually locate). Here
are the detailed enviroment infos on my test:
1. Remote shared Machine: Win2k server with .net framework1.1 installed
shared one folder as the root folder of a certain web application.

2. Server Host Machine(where host the webapplication in IIS): WinXP
Professional with .net framework1.1 installed. And the two machines are in
the same domain so When creating the virutal directory on the XP box, I
paste the certain UNC path (\\servername\sharedfoldername) and then select
a DomainAccount which are administrator on both machine. Then, when I visit
the page in the web application and the page has the following code in
Page_Load:
Response.Write("<br>" + Server.MapPath("."));

Then, the output display the certain UNC path on the WIN2K
mathine((\\servername\sharedfoldername) rather than the physical path on
the WINXP BOX. I've also tried the contrary( share a folder on the XP box
and host the IIS Virutal Directory on the WIN2K machine, still use the
DomainAccount when accessing the UNC folder
in IIS manager).

So I think you may have a check on the above steps I listed to see whether
they can provide any clues. Also, I recommend that you also perform such a
test on your side to see whether it works. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Steven-

Rather than have the whole site located on a share from a remote machine,
can you create a Web site locally, then create a virtual directory under the
site that points to a remote machine share?

-Jay

"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> wrote in message
news:vnIAo%23UHEHA.3444@.cpmsftngxa06.phx.gbl...
> Hi Jay,
> Thanks for your followup. Regarding on this issue, I've done a general
test
> on my side and found the Server.MapPath did return the UNCPath of the
> remote server(where the asp.net files and assemlby actually locate). Here
> are the detailed enviroment infos on my test:
> 1. Remote shared Machine: Win2k server with .net framework1.1 installed
> shared one folder as the root folder of a certain web application.
> 2. Server Host Machine(where host the webapplication in IIS): WinXP
> Professional with .net framework1.1 installed. And the two machines are
in
> the same domain so When creating the virutal directory on the XP box, I
> paste the certain UNC path (\\servername\sharedfoldername) and then select
> a DomainAccount which are administrator on both machine. Then, when I
visit
> the page in the web application and the page has the following code in
> Page_Load:
> Response.Write("<br>" + Server.MapPath("."));
> Then, the output display the certain UNC path on the WIN2K
> mathine((\\servername\sharedfoldername) rather than the physical path on
> the WINXP BOX. I've also tried the contrary( share a folder on the XP box
> and host the IIS Virutal Directory on the WIN2K machine, still use the
> DomainAccount when accessing the UNC folder
> in IIS manager).
> So I think you may have a check on the above steps I listed to see whether
> they can provide any clues. Also, I recommend that you also perform such a
> test on your side to see whether it works. Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
>
Hi Jay,

In fact, my test is just Virutal Directory based rather than site based. I
just create a Virutal Directory under the local IIS's default site and set
its "Network Directory" path as a UNC path on another remote machine.
However, I think the key point should be the "Connect As.." account , I
used a PowerFull Domain account which has the administrator permission on
the remote machine. So I think we may have a further check on the
security. Do you think so? Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Server.Mappath and Virtual Directories

Hello,
I have a web application with a virtual directory in it. With 'virtual
directory' i mean
a folder whose physical path is different from the physical path of the
application, but in which Web Sharing is active.
For example:
my application is in "C:\Inetpub\wwwroot\MyApp",
the Virtual folder is in "C:\VirtualFolder",
and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
How can I get, from code, the real physical path of the virtual folder?
I tried with Server.Mappath, but I found that it returns
"C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
Thanks
Lorenzo
LorenzoGood catch, Lorenzo.
The behavior is as you describe it, and I agree that Server.MapPath should
reflect the true physical directory of a virtual directory within an Applica
tion.
Please go to the Product Feedback Center :
http://lab.msdn.microsoft.com/produ...ck/default.aspx
and file a bug for that behavior.
You will need a Passport account to file a bug at the Feedback Center.
Thank you!
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
> Hello,
> I have a web application with a virtual directory in it. With 'virtual
> directory' i mean
> a folder whose physical path is different from the physical path of the
> application, but in which Web Sharing is active.
> For example:
> my application is in "C:\Inetpub\wwwroot\MyApp",
> the Virtual folder is in "C:\VirtualFolder",
> and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
> How can I get, from code, the real physical path of the virtual folder?
> I tried with Server.Mappath, but I found that it returns
> "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
> Thanks
> Lorenzo
> --
> Lorenzo
Thank you for the answer: I will surely report the 'Bug'.
In the meantime, could you (or someone other) suggest me another way to do
the same thing, or a workaround?
Thanks
--
Lorenzo
"Juan T. Llibre" ha scritto:

> Good catch, Lorenzo.
> The behavior is as you describe it, and I agree that Server.MapPath should
> reflect the true physical directory of a virtual directory within an Appli
cation.
> Please go to the Product Feedback Center :
> http://lab.msdn.microsoft.com/produ...ck/default.aspx
> and file a bug for that behavior.
> You will need a Passport account to file a bug at the Feedback Center.
> Thank you!
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
>
>
The bug was already reported!
(see:
http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
)
Reading the answer i realized that this happens only in debug mode, due to
the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
Cassini!
Lorenzo
"Juan T. Llibre" ha scritto:

> Good catch, Lorenzo.
> The behavior is as you describe it, and I agree that Server.MapPath should
> reflect the true physical directory of a virtual directory within an Appli
cation.
> Please go to the Product Feedback Center :
> http://lab.msdn.microsoft.com/produ...ck/default.aspx
> and file a bug for that behavior.
> You will need a Passport account to file a bug at the Feedback Center.
> Thank you!
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
>
>
re:
> Thank you for the answer: I will surely report the 'Bug'.
Please do so.
That's the only way to let the Dev Team know what we know doesn't work,
so they can try to fix it...and that's the best way to get a better product.
re:
> In the meantime, could you (or someone other) suggest me another way to do
> the same thing, or a workaround?
The only workaround I can think of is not to use Server.MapPath
and, instead, hard-code the physical path.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:6096D10D-DED4-4CFD-9075-1BB0C56C78A1@.microsoft.com...
> Thank you for the answer: I will surely report the 'Bug'.
> In the meantime, could you (or someone other) suggest me another way to do
> the same thing, or a workaround?
> Thanks
> --
> Lorenzo
>
> "Juan T. Llibre" ha scritto:
>
Yes, please bug it as happening under IIS, too.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
> The bug was already reported!
> (see:
> http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
> )
> Reading the answer i realized that this happens only in debug mode, due to
> the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead o
f
> Cassini!
> Lorenzo
> "Juan T. Llibre" ha scritto:
>
No, it happens only with Cassini, I just verified it!
Lorenzo
"Juan T. Llibre" ha scritto:

> Yes, please bug it as happening under IIS, too.
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
>
>
>
Actually, I did quite a bit of testing with IIS after I read your post.
It happens with IIS and I can repro it.
You are mistaken about it only happening with Cassini.
File the bug or, if you are not up to it, I will.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
> No, it happens only with Cassini, I just verified it!
> --
> Lorenzo
> "Juan T. Llibre" ha scritto:
>
Maybe I did a test sligthly different?
I Wasn't in debug mode.
In the first test, I tried opening IE and writing directly a path like this:
http:\\localhost\Projects\2006\myapp\Web
Service.asmx
(I use a WebService for the test: when invoked, it returns the path of a
virtual directory, generated via Server.Mappath).
This test works correctly!
In the second test, I tried opening IE and writing directly a path like this
:
http:\\localhost:1263\myapp\WebService.asmx
(in this way I use Cassini, it's right?).
In this test the problem happens!
I made some error?
Lorenzo
"Juan T. Llibre" ha scritto:

> Actually, I did quite a bit of testing with IIS after I read your post.
> It happens with IIS and I can repro it.
> You are mistaken about it only happening with Cassini.
> File the bug or, if you are not up to it, I will.
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
>
>
>
You never mentioned that you were talking about a Web Service.
I tested on an aspx page, which is the *usual* type of "web application",
which is all you mentioned in your original post, so, yes, it does make for
"slightly different" testing conditions.
Post webservice.asmx so we can dissect the code in it.
It dosn't have earth-shaking super-secret code in it, does it ?
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:BB12EEBF-1CEE-46D3-978C-AC47FA0D7CE9@.microsoft.com...
> Maybe I did a test sligthly different?
> I Wasn't in debug mode.
> In the first test, I tried opening IE and writing directly a path like thi
s:
> http:\\localhost\Projects\2006\myapp\Web
Service.asmx
> (I use a WebService for the test: when invoked, it returns the path of a
> virtual directory, generated via Server.Mappath).
> This test works correctly!
> In the second test, I tried opening IE and writing directly a path like th
is:
> http:\\localhost:1263\myapp\WebService.asmx
> (in this way I use Cassini, it's right?).
> In this test the problem happens!
> I made some error?
> --
> Lorenzo
> "Juan T. Llibre" ha scritto:
>

Server.Mappath and Virtual Directories

Hello,

I have a web application with a virtual directory in it. With 'virtual
directory' i mean
a folder whose physical path is different from the physical path of the
application, but in which Web Sharing is active.
For example:
my application is in "C:\Inetpub\wwwroot\MyApp",
the Virtual folder is in "C:\VirtualFolder",
and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".

How can I get, from code, the real physical path of the virtual folder?
I tried with Server.Mappath, but I found that it returns
"C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"

Thanks
Lorenzo

--
LorenzoGood catch, Lorenzo.

The behavior is as you describe it, and I agree that Server.MapPath should
reflect the true physical directory of a virtual directory within an Application.

Please go to the Product Feedback Center :
http://lab.msdn.microsoft.com/produ...ck/default.aspx
and file a bug for that behavior.

You will need a Passport account to file a bug at the Feedback Center.

Thank you!

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
> Hello,
> I have a web application with a virtual directory in it. With 'virtual
> directory' i mean
> a folder whose physical path is different from the physical path of the
> application, but in which Web Sharing is active.
> For example:
> my application is in "C:\Inetpub\wwwroot\MyApp",
> the Virtual folder is in "C:\VirtualFolder",
> and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
> How can I get, from code, the real physical path of the virtual folder?
> I tried with Server.Mappath, but I found that it returns
> "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
> Thanks
> Lorenzo
> --
> Lorenzo
Thank you for the answer: I will surely report the 'Bug'.

In the meantime, could you (or someone other) suggest me another way to do
the same thing, or a workaround?

Thanks
--
Lorenzo

"Juan T. Llibre" ha scritto:

> Good catch, Lorenzo.
> The behavior is as you describe it, and I agree that Server.MapPath should
> reflect the true physical directory of a virtual directory within an Application.
> Please go to the Product Feedback Center :
> http://lab.msdn.microsoft.com/produ...ck/default.aspx
> and file a bug for that behavior.
> You will need a Passport account to file a bug at the Feedback Center.
> Thank you!
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
> > Hello,
> > I have a web application with a virtual directory in it. With 'virtual
> > directory' i mean
> > a folder whose physical path is different from the physical path of the
> > application, but in which Web Sharing is active.
> > For example:
> > my application is in "C:\Inetpub\wwwroot\MyApp",
> > the Virtual folder is in "C:\VirtualFolder",
> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
> > How can I get, from code, the real physical path of the virtual folder?
> > I tried with Server.Mappath, but I found that it returns
> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
> > Thanks
> > Lorenzo
> > --
> > Lorenzo
>
The bug was already reported!

(see:
http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
)

Reading the answer i realized that this happens only in debug mode, due to
the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
Cassini!

--
Lorenzo

"Juan T. Llibre" ha scritto:

> Good catch, Lorenzo.
> The behavior is as you describe it, and I agree that Server.MapPath should
> reflect the true physical directory of a virtual directory within an Application.
> Please go to the Product Feedback Center :
> http://lab.msdn.microsoft.com/produ...ck/default.aspx
> and file a bug for that behavior.
> You will need a Passport account to file a bug at the Feedback Center.
> Thank you!
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
> > Hello,
> > I have a web application with a virtual directory in it. With 'virtual
> > directory' i mean
> > a folder whose physical path is different from the physical path of the
> > application, but in which Web Sharing is active.
> > For example:
> > my application is in "C:\Inetpub\wwwroot\MyApp",
> > the Virtual folder is in "C:\VirtualFolder",
> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
> > How can I get, from code, the real physical path of the virtual folder?
> > I tried with Server.Mappath, but I found that it returns
> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
> > Thanks
> > Lorenzo
> > --
> > Lorenzo
>
re:
> Thank you for the answer: I will surely report the 'Bug'.

Please do so.

That's the only way to let the Dev Team know what we know doesn't work,
so they can try to fix it...and that's the best way to get a better product.

re:
> In the meantime, could you (or someone other) suggest me another way to do
> the same thing, or a workaround?

The only workaround I can think of is not to use Server.MapPath
and, instead, hard-code the physical path.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:6096D10D-DED4-4CFD-9075-1BB0C56C78A1@.microsoft.com...
> Thank you for the answer: I will surely report the 'Bug'.
> In the meantime, could you (or someone other) suggest me another way to do
> the same thing, or a workaround?
> Thanks
> --
> Lorenzo
>
> "Juan T. Llibre" ha scritto:
>> Good catch, Lorenzo.
>>
>> The behavior is as you describe it, and I agree that Server.MapPath should
>> reflect the true physical directory of a virtual directory within an Application.
>>
>> Please go to the Product Feedback Center :
>> http://lab.msdn.microsoft.com/produ...ck/default.aspx
>> and file a bug for that behavior.
>>
>> You will need a Passport account to file a bug at the Feedback Center.
>>
>> Thank you!
>>
>>
>>
>> Juan T. Llibre, asp.net MVP
>> aspnetfaq.com : http://www.aspnetfaq.com/
>> asp.net faq : http://asp.net.do/faq/
>> foros de asp.net, en espaol : http://asp.net.do/foros/
>> ===================================
>> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
>> > Hello,
>>> > I have a web application with a virtual directory in it. With 'virtual
>> > directory' i mean
>> > a folder whose physical path is different from the physical path of the
>> > application, but in which Web Sharing is active.
>> > For example:
>> > my application is in "C:\Inetpub\wwwroot\MyApp",
>> > the Virtual folder is in "C:\VirtualFolder",
>> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
>>> > How can I get, from code, the real physical path of the virtual folder?
>> > I tried with Server.Mappath, but I found that it returns
>> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
>>> > Thanks
>> > Lorenzo
>>> > --
>> > Lorenzo
>>
>>
>
Yes, please bug it as happening under IIS, too.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
> The bug was already reported!
> (see:
> http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
> )
> Reading the answer i realized that this happens only in debug mode, due to
> the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
> Cassini!
> Lorenzo

> "Juan T. Llibre" ha scritto:
>> Good catch, Lorenzo.
>>
>> The behavior is as you describe it, and I agree that Server.MapPath should
>> reflect the true physical directory of a virtual directory within an Application.
>>
>> Please go to the Product Feedback Center :
>> http://lab.msdn.microsoft.com/produ...ck/default.aspx
>> and file a bug for that behavior.
>>
>> You will need a Passport account to file a bug at the Feedback Center.
>>
>> Thank you!
>>
>>
>>
>> Juan T. Llibre, asp.net MVP
>> aspnetfaq.com : http://www.aspnetfaq.com/
>> asp.net faq : http://asp.net.do/faq/
>> foros de asp.net, en espaol : http://asp.net.do/foros/
>> ===================================
>> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
>> > Hello,
>>> > I have a web application with a virtual directory in it. With 'virtual
>> > directory' i mean
>> > a folder whose physical path is different from the physical path of the
>> > application, but in which Web Sharing is active.
>> > For example:
>> > my application is in "C:\Inetpub\wwwroot\MyApp",
>> > the Virtual folder is in "C:\VirtualFolder",
>> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
>>> > How can I get, from code, the real physical path of the virtual folder?
>> > I tried with Server.Mappath, but I found that it returns
>> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
>>> > Thanks
>> > Lorenzo
>>> > --
>> > Lorenzo
>>
>>
>
No, it happens only with Cassini, I just verified it!

--
Lorenzo

"Juan T. Llibre" ha scritto:

> Yes, please bug it as happening under IIS, too.
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
> > The bug was already reported!
> > (see:
> > http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
> > )
> > Reading the answer i realized that this happens only in debug mode, due to
> > the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
> > Cassini!
> > Lorenzo
>
> > "Juan T. Llibre" ha scritto:
> >> Good catch, Lorenzo.
> >>
> >> The behavior is as you describe it, and I agree that Server.MapPath should
> >> reflect the true physical directory of a virtual directory within an Application.
> >>
> >> Please go to the Product Feedback Center :
> >> http://lab.msdn.microsoft.com/produ...ck/default.aspx
> >> and file a bug for that behavior.
> >>
> >> You will need a Passport account to file a bug at the Feedback Center.
> >>
> >> Thank you!
> >>
> >>
> >>
> >> Juan T. Llibre, asp.net MVP
> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> asp.net faq : http://asp.net.do/faq/
> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> ===================================
> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
> >> > Hello,
> >> >> > I have a web application with a virtual directory in it. With 'virtual
> >> > directory' i mean
> >> > a folder whose physical path is different from the physical path of the
> >> > application, but in which Web Sharing is active.
> >> > For example:
> >> > my application is in "C:\Inetpub\wwwroot\MyApp",
> >> > the Virtual folder is in "C:\VirtualFolder",
> >> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
> >> >> > How can I get, from code, the real physical path of the virtual folder?
> >> > I tried with Server.Mappath, but I found that it returns
> >> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
> >> >> > Thanks
> >> > Lorenzo
> >> >> > --
> >> > Lorenzo
> >>
> >>
> >>
>
Actually, I did quite a bit of testing with IIS after I read your post.
It happens with IIS and I can repro it.

You are mistaken about it only happening with Cassini.
File the bug or, if you are not up to it, I will.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
> No, it happens only with Cassini, I just verified it!
> --
> Lorenzo

> "Juan T. Llibre" ha scritto:
>> Yes, please bug it as happening under IIS, too.
>>
>>
>>
>> Juan T. Llibre, asp.net MVP
>> aspnetfaq.com : http://www.aspnetfaq.com/
>> asp.net faq : http://asp.net.do/faq/
>> foros de asp.net, en espaol : http://asp.net.do/foros/
>> ===================================
>> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
>> > The bug was already reported!
>>> > (see:
>> > http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
>> > )
>>> > Reading the answer i realized that this happens only in debug mode, due to
>> > the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
>> > Cassini!
>> > Lorenzo
>>
>>
>> > "Juan T. Llibre" ha scritto:
>>> >> Good catch, Lorenzo.
>> >>
>> >> The behavior is as you describe it, and I agree that Server.MapPath should
>> >> reflect the true physical directory of a virtual directory within an Application.
>> >>
>> >> Please go to the Product Feedback Center :
>> >> http://lab.msdn.microsoft.com/produ...ck/default.aspx
>> >> and file a bug for that behavior.
>> >>
>> >> You will need a Passport account to file a bug at the Feedback Center.
>> >>
>> >> Thank you!
>> >>
>> >>
>> >>
>> >> Juan T. Llibre, asp.net MVP
>> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> asp.net faq : http://asp.net.do/faq/
>> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> ===================================
>> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
>> >> > Hello,
>> >>> >> > I have a web application with a virtual directory in it. With 'virtual
>> >> > directory' i mean
>> >> > a folder whose physical path is different from the physical path of the
>> >> > application, but in which Web Sharing is active.
>> >> > For example:
>> >> > my application is in "C:\Inetpub\wwwroot\MyApp",
>> >> > the Virtual folder is in "C:\VirtualFolder",
>> >> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
>> >>> >> > How can I get, from code, the real physical path of the virtual folder?
>> >> > I tried with Server.Mappath, but I found that it returns
>> >> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
>> >>> >> > Thanks
>> >> > Lorenzo
>> >>> >> > --
>> >> > Lorenzo
>> >>
>> >>
>> >>
>>
>>
>
Maybe I did a test sligthly different?

I Wasn't in debug mode.

In the first test, I tried opening IE and writing directly a path like this:
http:\\localhost\Projects\2006\myapp\WebService.as mx
(I use a WebService for the test: when invoked, it returns the path of a
virtual directory, generated via Server.Mappath).
This test works correctly!

In the second test, I tried opening IE and writing directly a path like this:
http:\\localhost:1263\myapp\WebService.asmx
(in this way I use Cassini, it's right?).
In this test the problem happens!

I made some error?

--
Lorenzo

"Juan T. Llibre" ha scritto:

> Actually, I did quite a bit of testing with IIS after I read your post.
> It happens with IIS and I can repro it.
> You are mistaken about it only happening with Cassini.
> File the bug or, if you are not up to it, I will.
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
> > No, it happens only with Cassini, I just verified it!
> > --
> > Lorenzo
>
> > "Juan T. Llibre" ha scritto:
> >> Yes, please bug it as happening under IIS, too.
> >>
> >>
> >>
> >> Juan T. Llibre, asp.net MVP
> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> asp.net faq : http://asp.net.do/faq/
> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> ===================================
> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
> >> > The bug was already reported!
> >> >> > (see:
> >> > http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
> >> > )
> >> >> > Reading the answer i realized that this happens only in debug mode, due to
> >> > the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
> >> > Cassini!
> >> > Lorenzo
> >>
> >>
> >> > "Juan T. Llibre" ha scritto:
> >> >> >> Good catch, Lorenzo.
> >> >>
> >> >> The behavior is as you describe it, and I agree that Server.MapPath should
> >> >> reflect the true physical directory of a virtual directory within an Application.
> >> >>
> >> >> Please go to the Product Feedback Center :
> >> >> http://lab.msdn.microsoft.com/produ...ck/default.aspx
> >> >> and file a bug for that behavior.
> >> >>
> >> >> You will need a Passport account to file a bug at the Feedback Center.
> >> >>
> >> >> Thank you!
> >> >>
> >> >>
> >> >>
> >> >> Juan T. Llibre, asp.net MVP
> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> >> asp.net faq : http://asp.net.do/faq/
> >> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> >> ===================================
> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> >> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
> >> >> > Hello,
> >> >> >> >> > I have a web application with a virtual directory in it. With 'virtual
> >> >> > directory' i mean
> >> >> > a folder whose physical path is different from the physical path of the
> >> >> > application, but in which Web Sharing is active.
> >> >> > For example:
> >> >> > my application is in "C:\Inetpub\wwwroot\MyApp",
> >> >> > the Virtual folder is in "C:\VirtualFolder",
> >> >> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
> >> >> >> >> > How can I get, from code, the real physical path of the virtual folder?
> >> >> > I tried with Server.Mappath, but I found that it returns
> >> >> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
> >> >> >> >> > Thanks
> >> >> > Lorenzo
> >> >> >> >> > --
> >> >> > Lorenzo
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
You never mentioned that you were talking about a Web Service.

I tested on an aspx page, which is the *usual* type of "web application",
which is all you mentioned in your original post, so, yes, it does make for
"slightly different" testing conditions.

Post webservice.asmx so we can dissect the code in it.
It dosn't have earth-shaking super-secret code in it, does it ?

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:BB12EEBF-1CEE-46D3-978C-AC47FA0D7CE9@.microsoft.com...
> Maybe I did a test sligthly different?
> I Wasn't in debug mode.
> In the first test, I tried opening IE and writing directly a path like this:
> http:\\localhost\Projects\2006\myapp\WebService.as mx
> (I use a WebService for the test: when invoked, it returns the path of a
> virtual directory, generated via Server.Mappath).
> This test works correctly!
> In the second test, I tried opening IE and writing directly a path like this:
> http:\\localhost:1263\myapp\WebService.asmx
> (in this way I use Cassini, it's right?).
> In this test the problem happens!
> I made some error?
> --
> Lorenzo

> "Juan T. Llibre" ha scritto:
>> Actually, I did quite a bit of testing with IIS after I read your post.
>> It happens with IIS and I can repro it.
>>
>> You are mistaken about it only happening with Cassini.
>> File the bug or, if you are not up to it, I will.
>>
>>
>>
>>
>> Juan T. Llibre, asp.net MVP
>> aspnetfaq.com : http://www.aspnetfaq.com/
>> asp.net faq : http://asp.net.do/faq/
>> foros de asp.net, en espaol : http://asp.net.do/foros/
>> ===================================
>> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
>> > No, it happens only with Cassini, I just verified it!
>> > --
>> > Lorenzo
>>
>>
>> > "Juan T. Llibre" ha scritto:
>>> >> Yes, please bug it as happening under IIS, too.
>> >>
>> >>
>> >>
>> >> Juan T. Llibre, asp.net MVP
>> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> asp.net faq : http://asp.net.do/faq/
>> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> ===================================
>> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
>> >> > The bug was already reported!
>> >>> >> > (see:
>> >> > http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
>> >> > )
>> >>> >> > Reading the answer i realized that this happens only in debug mode, due to
>> >> > the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
>> >> > Cassini!
>> >> > Lorenzo
>> >>
>> >>
>> >> > "Juan T. Llibre" ha scritto:
>> >>> >> >> Good catch, Lorenzo.
>> >> >>
>> >> >> The behavior is as you describe it, and I agree that Server.MapPath should
>> >> >> reflect the true physical directory of a virtual directory within an Application.
>> >> >>
>> >> >> Please go to the Product Feedback Center :
>> >> >> http://lab.msdn.microsoft.com/produ...ck/default.aspx
>> >> >> and file a bug for that behavior.
>> >> >>
>> >> >> You will need a Passport account to file a bug at the Feedback Center.
>> >> >>
>> >> >> Thank you!
>> >> >>
>> >> >>
>> >> >>
>> >> >> Juan T. Llibre, asp.net MVP
>> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> >> asp.net faq : http://asp.net.do/faq/
>> >> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> >> ===================================
>> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> >> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
>> >> >> > Hello,
>> >> >>> >> >> > I have a web application with a virtual directory in it. With 'virtual
>> >> >> > directory' i mean
>> >> >> > a folder whose physical path is different from the physical path of the
>> >> >> > application, but in which Web Sharing is active.
>> >> >> > For example:
>> >> >> > my application is in "C:\Inetpub\wwwroot\MyApp",
>> >> >> > the Virtual folder is in "C:\VirtualFolder",
>> >> >> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
>> >> >>> >> >> > How can I get, from code, the real physical path of the virtual folder?
>> >> >> > I tried with Server.Mappath, but I found that it returns
>> >> >> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
>> >> >>> >> >> > Thanks
>> >> >> > Lorenzo
>> >> >>> >> >> > --
>> >> >> > Lorenzo
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>
Today I'm out of office, but tomorrow, I will try with a web page (I thought
it was the same thing than a webservice), and I'll post to you my code.

See you tomorrow!

--
Lorenzo

"Juan T. Llibre" ha scritto:

> You never mentioned that you were talking about a Web Service.
> I tested on an aspx page, which is the *usual* type of "web application",
> which is all you mentioned in your original post, so, yes, it does make for
> "slightly different" testing conditions.
> Post webservice.asmx so we can dissect the code in it.
> It dosn't have earth-shaking super-secret code in it, does it ?
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:BB12EEBF-1CEE-46D3-978C-AC47FA0D7CE9@.microsoft.com...
> > Maybe I did a test sligthly different?
> > I Wasn't in debug mode.
> > In the first test, I tried opening IE and writing directly a path like this:
> > http:\\localhost\Projects\2006\myapp\WebService.as mx
> > (I use a WebService for the test: when invoked, it returns the path of a
> > virtual directory, generated via Server.Mappath).
> > This test works correctly!
> > In the second test, I tried opening IE and writing directly a path like this:
> > http:\\localhost:1263\myapp\WebService.asmx
> > (in this way I use Cassini, it's right?).
> > In this test the problem happens!
> > I made some error?
> > --
> > Lorenzo
>
> > "Juan T. Llibre" ha scritto:
> >> Actually, I did quite a bit of testing with IIS after I read your post.
> >> It happens with IIS and I can repro it.
> >>
> >> You are mistaken about it only happening with Cassini.
> >> File the bug or, if you are not up to it, I will.
> >>
> >>
> >>
> >>
> >> Juan T. Llibre, asp.net MVP
> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> asp.net faq : http://asp.net.do/faq/
> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> ===================================
> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
> >> > No, it happens only with Cassini, I just verified it!
> >> > --
> >> > Lorenzo
> >>
> >>
> >> > "Juan T. Llibre" ha scritto:
> >> >> >> Yes, please bug it as happening under IIS, too.
> >> >>
> >> >>
> >> >>
> >> >> Juan T. Llibre, asp.net MVP
> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> >> asp.net faq : http://asp.net.do/faq/
> >> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> >> ===================================
> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> >> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
> >> >> > The bug was already reported!
> >> >> >> >> > (see:
> >> >> > http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
> >> >> > )
> >> >> >> >> > Reading the answer i realized that this happens only in debug mode, due to
> >> >> > the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
> >> >> > Cassini!
> >> >> > Lorenzo
> >> >>
> >> >>
> >> >> > "Juan T. Llibre" ha scritto:
> >> >> >> >> >> Good catch, Lorenzo.
> >> >> >>
> >> >> >> The behavior is as you describe it, and I agree that Server.MapPath should
> >> >> >> reflect the true physical directory of a virtual directory within an Application.
> >> >> >>
> >> >> >> Please go to the Product Feedback Center :
> >> >> >> http://lab.msdn.microsoft.com/produ...ck/default.aspx
> >> >> >> and file a bug for that behavior.
> >> >> >>
> >> >> >> You will need a Passport account to file a bug at the Feedback Center.
> >> >> >>
> >> >> >> Thank you!
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> Juan T. Llibre, asp.net MVP
> >> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> >> >> asp.net faq : http://asp.net.do/faq/
> >> >> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> >> >> ===================================
> >> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> >> >> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
> >> >> >> > Hello,
> >> >> >> >> >> >> > I have a web application with a virtual directory in it. With 'virtual
> >> >> >> > directory' i mean
> >> >> >> > a folder whose physical path is different from the physical path of the
> >> >> >> > application, but in which Web Sharing is active.
> >> >> >> > For example:
> >> >> >> > my application is in "C:\Inetpub\wwwroot\MyApp",
> >> >> >> > the Virtual folder is in "C:\VirtualFolder",
> >> >> >> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
> >> >> >> >> >> >> > How can I get, from code, the real physical path of the virtual folder?
> >> >> >> > I tried with Server.Mappath, but I found that it returns
> >> >> >> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
> >> >> >> >> >> >> > Thanks
> >> >> >> > Lorenzo
> >> >> >> >> >> >> > --
> >> >> >> > Lorenzo
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
I tested the same thing with a webpage:
the problem was identical, as I supposed.

The code to reproduce the test is quite simple:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)Handles Me.Load
Label2.Text = Server.MapPath("Prova")
End Sub

(where Label2 is a Label Webcontrol and "Prova" is the virtual directory)

The result is correct if, in IE, I reach the page using this address:
http:\\localhost\Projects\2006\myapp\default2.aspx
(so using IIS)

The result is wrong if, in IE, I reach the page using this address:
http:\\localhost:1263\myapp\default2.aspx
(so using Cassini)

With the webservice, the code was:

<WebMethod()> _
Public Function AbsoluteEventsPath() As String
Return Server.MapPath("Prova")
End Function

In my opinion, this is exactly the situation described in the filed bug, and
it's due to a 'limitation' of Cassini that does not behave like IIS.
(Luckily, this is not a big deal for me, because in the production server I
use IIS).

If you went deeper than me and found a different situation, file it by
yourself, and please notify it to me, that I am very curoius!

(my e-mail is lorenzoaaa@.REMOVE_MEtiscali.it)

Bye
Lorenzo

--
Lorenzo

"Juan T. Llibre" ha scritto:

> You never mentioned that you were talking about a Web Service.
> I tested on an aspx page, which is the *usual* type of "web application",
> which is all you mentioned in your original post, so, yes, it does make for
> "slightly different" testing conditions.
> Post webservice.asmx so we can dissect the code in it.
> It dosn't have earth-shaking super-secret code in it, does it ?
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:BB12EEBF-1CEE-46D3-978C-AC47FA0D7CE9@.microsoft.com...
> > Maybe I did a test sligthly different?
> > I Wasn't in debug mode.
> > In the first test, I tried opening IE and writing directly a path like this:
> > http:\\localhost\Projects\2006\myapp\WebService.as mx
> > (I use a WebService for the test: when invoked, it returns the path of a
> > virtual directory, generated via Server.Mappath).
> > This test works correctly!
> > In the second test, I tried opening IE and writing directly a path like this:
> > http:\\localhost:1263\myapp\WebService.asmx
> > (in this way I use Cassini, it's right?).
> > In this test the problem happens!
> > I made some error?
> > --
> > Lorenzo
>
> > "Juan T. Llibre" ha scritto:
> >> Actually, I did quite a bit of testing with IIS after I read your post.
> >> It happens with IIS and I can repro it.
> >>
> >> You are mistaken about it only happening with Cassini.
> >> File the bug or, if you are not up to it, I will.
> >>
> >>
> >>
> >>
> >> Juan T. Llibre, asp.net MVP
> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> asp.net faq : http://asp.net.do/faq/
> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> ===================================
> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
> >> > No, it happens only with Cassini, I just verified it!
> >> > --
> >> > Lorenzo
> >>
> >>
> >> > "Juan T. Llibre" ha scritto:
> >> >> >> Yes, please bug it as happening under IIS, too.
> >> >>
> >> >>
> >> >>
> >> >> Juan T. Llibre, asp.net MVP
> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> >> asp.net faq : http://asp.net.do/faq/
> >> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> >> ===================================
> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> >> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
> >> >> > The bug was already reported!
> >> >> >> >> > (see:
> >> >> > http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
> >> >> > )
> >> >> >> >> > Reading the answer i realized that this happens only in debug mode, due to
> >> >> > the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
> >> >> > Cassini!
> >> >> > Lorenzo
> >> >>
> >> >>
> >> >> > "Juan T. Llibre" ha scritto:
> >> >> >> >> >> Good catch, Lorenzo.
> >> >> >>
> >> >> >> The behavior is as you describe it, and I agree that Server.MapPath should
> >> >> >> reflect the true physical directory of a virtual directory within an Application.
> >> >> >>
> >> >> >> Please go to the Product Feedback Center :
> >> >> >> http://lab.msdn.microsoft.com/produ...ck/default.aspx
> >> >> >> and file a bug for that behavior.
> >> >> >>
> >> >> >> You will need a Passport account to file a bug at the Feedback Center.
> >> >> >>
> >> >> >> Thank you!
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> Juan T. Llibre, asp.net MVP
> >> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> >> >> asp.net faq : http://asp.net.do/faq/
> >> >> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> >> >> ===================================
> >> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> >> >> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
> >> >> >> > Hello,
> >> >> >> >> >> >> > I have a web application with a virtual directory in it. With 'virtual
> >> >> >> > directory' i mean
> >> >> >> > a folder whose physical path is different from the physical path of the
> >> >> >> > application, but in which Web Sharing is active.
> >> >> >> > For example:
> >> >> >> > my application is in "C:\Inetpub\wwwroot\MyApp",
> >> >> >> > the Virtual folder is in "C:\VirtualFolder",
> >> >> >> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
> >> >> >> >> >> >> > How can I get, from code, the real physical path of the virtual folder?
> >> >> >> > I tried with Server.Mappath, but I found that it returns
> >> >> >> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
> >> >> >> >> >> >> > Thanks
> >> >> >> > Lorenzo
> >> >> >> >> >> >> > --
> >> >> >> > Lorenzo
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
Try, if "Prova" is a virtual directory/application :

Server.MapPath("/Prova")

Notice the slash...

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:A68BE1E2-6252-443E-BBEE-E7A328542458@.microsoft.com...
>I tested the same thing with a webpage:
> the problem was identical, as I supposed.
> The code to reproduce the test is quite simple:
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)Handles Me.Load
> Label2.Text = Server.MapPath("Prova")
> End Sub
> (where Label2 is a Label Webcontrol and "Prova" is the virtual directory)
>
> The result is correct if, in IE, I reach the page using this address:
> http:\\localhost\Projects\2006\myapp\default2.aspx
> (so using IIS)
> The result is wrong if, in IE, I reach the page using this address:
> http:\\localhost:1263\myapp\default2.aspx
> (so using Cassini)
> With the webservice, the code was:
> <WebMethod()> _
> Public Function AbsoluteEventsPath() As String
> Return Server.MapPath("Prova")
> End Function
>
> In my opinion, this is exactly the situation described in the filed bug, and
> it's due to a 'limitation' of Cassini that does not behave like IIS.
> (Luckily, this is not a big deal for me, because in the production server I
> use IIS).
> If you went deeper than me and found a different situation, file it by
> yourself, and please notify it to me, that I am very curoius!
> (my e-mail is lorenzoaaa@.REMOVE_MEtiscali.it)
> Bye
> Lorenzo
> --
> Lorenzo
>
> "Juan T. Llibre" ha scritto:
>> You never mentioned that you were talking about a Web Service.
>>
>> I tested on an aspx page, which is the *usual* type of "web application",
>> which is all you mentioned in your original post, so, yes, it does make for
>> "slightly different" testing conditions.
>>
>> Post webservice.asmx so we can dissect the code in it.
>> It dosn't have earth-shaking super-secret code in it, does it ?
>>
>>
>>
>>
>> Juan T. Llibre, asp.net MVP
>> aspnetfaq.com : http://www.aspnetfaq.com/
>> asp.net faq : http://asp.net.do/faq/
>> foros de asp.net, en espaol : http://asp.net.do/foros/
>> ===================================
>> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> news:BB12EEBF-1CEE-46D3-978C-AC47FA0D7CE9@.microsoft.com...
>> > Maybe I did a test sligthly different?
>>> > I Wasn't in debug mode.
>>> > In the first test, I tried opening IE and writing directly a path like this:
>> > http:\\localhost\Projects\2006\myapp\WebService.as mx
>> > (I use a WebService for the test: when invoked, it returns the path of a
>> > virtual directory, generated via Server.Mappath).
>> > This test works correctly!
>>> > In the second test, I tried opening IE and writing directly a path like this:
>> > http:\\localhost:1263\myapp\WebService.asmx
>> > (in this way I use Cassini, it's right?).
>> > In this test the problem happens!
>>> > I made some error?
>> > --
>> > Lorenzo
>>
>>
>> > "Juan T. Llibre" ha scritto:
>>> >> Actually, I did quite a bit of testing with IIS after I read your post.
>> >> It happens with IIS and I can repro it.
>> >>
>> >> You are mistaken about it only happening with Cassini.
>> >> File the bug or, if you are not up to it, I will.
>> >>
>> >>
>> >>
>> >>
>> >> Juan T. Llibre, asp.net MVP
>> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> asp.net faq : http://asp.net.do/faq/
>> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> ===================================
>> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
>> >> > No, it happens only with Cassini, I just verified it!
>> >> > --
>> >> > Lorenzo
>> >>
>> >>
>> >> > "Juan T. Llibre" ha scritto:
>> >>> >> >> Yes, please bug it as happening under IIS, too.
>> >> >>
>> >> >>
>> >> >>
>> >> >> Juan T. Llibre, asp.net MVP
>> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> >> asp.net faq : http://asp.net.do/faq/
>> >> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> >> ===================================
>> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> >> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
>> >> >> > The bug was already reported!
>> >> >>> >> >> > (see:
>> >> >> > http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
>> >> >> > )
>> >> >>> >> >> > Reading the answer i realized that this happens only in debug mode, due to
>> >> >> > the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
>> >> >> > Cassini!
>> >> >> > Lorenzo
>> >> >>
>> >> >>
>> >> >> > "Juan T. Llibre" ha scritto:
>> >> >>> >> >> >> Good catch, Lorenzo.
>> >> >> >>
>> >> >> >> The behavior is as you describe it, and I agree that Server.MapPath should
>> >> >> >> reflect the true physical directory of a virtual directory within an Application.
>> >> >> >>
>> >> >> >> Please go to the Product Feedback Center :
>> >> >> >> http://lab.msdn.microsoft.com/produ...ck/default.aspx
>> >> >> >> and file a bug for that behavior.
>> >> >> >>
>> >> >> >> You will need a Passport account to file a bug at the Feedback Center.
>> >> >> >>
>> >> >> >> Thank you!
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> Juan T. Llibre, asp.net MVP
>> >> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> >> >> asp.net faq : http://asp.net.do/faq/
>> >> >> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> >> >> ===================================
>> >> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> >> >> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
>> >> >> >> > Hello,
>> >> >> >>> >> >> >> > I have a web application with a virtual directory in it. With 'virtual
>> >> >> >> > directory' i mean
>> >> >> >> > a folder whose physical path is different from the physical path of the
>> >> >> >> > application, but in which Web Sharing is active.
>> >> >> >> > For example:
>> >> >> >> > my application is in "C:\Inetpub\wwwroot\MyApp",
>> >> >> >> > the Virtual folder is in "C:\VirtualFolder",
>> >> >> >> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
>> >> >> >>> >> >> >> > How can I get, from code, the real physical path of the virtual folder?
>> >> >> >> > I tried with Server.Mappath, but I found that it returns
>> >> >> >> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
>> >> >> >>> >> >> >> > Thanks
>> >> >> >> > Lorenzo
>> >> >> >>> >> >> >> > --
>> >> >> >> > Lorenzo
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>
This isn't a correct test to try: if I write "/Prova", it searches a folder
directly in my localhost root, not in the current web application!
You can try by yourself. Notice the different behavior of Cassini and IIS:
IIS returns
"C:\Inetpub\wwwroot\Prova", Cassini raises an error!

By
--
Lorenzo

"Juan T. Llibre" ha scritto:

> Try, if "Prova" is a virtual directory/application :
> Server.MapPath("/Prova")
> Notice the slash...
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> ===================================
> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> news:A68BE1E2-6252-443E-BBEE-E7A328542458@.microsoft.com...
> >I tested the same thing with a webpage:
> > the problem was identical, as I supposed.
> > The code to reproduce the test is quite simple:
> > Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> > System.EventArgs)Handles Me.Load
> > Label2.Text = Server.MapPath("Prova")
> > End Sub
> > (where Label2 is a Label Webcontrol and "Prova" is the virtual directory)
> > The result is correct if, in IE, I reach the page using this address:
> > http:\\localhost\Projects\2006\myapp\default2.aspx
> > (so using IIS)
> > The result is wrong if, in IE, I reach the page using this address:
> > http:\\localhost:1263\myapp\default2.aspx
> > (so using Cassini)
> > With the webservice, the code was:
> > <WebMethod()> _
> > Public Function AbsoluteEventsPath() As String
> > Return Server.MapPath("Prova")
> > End Function
> > In my opinion, this is exactly the situation described in the filed bug, and
> > it's due to a 'limitation' of Cassini that does not behave like IIS.
> > (Luckily, this is not a big deal for me, because in the production server I
> > use IIS).
> > If you went deeper than me and found a different situation, file it by
> > yourself, and please notify it to me, that I am very curoius!
> > (my e-mail is lorenzoaaa@.REMOVE_MEtiscali.it)
> > Bye
> > Lorenzo
> > --
> > Lorenzo
> > "Juan T. Llibre" ha scritto:
> >> You never mentioned that you were talking about a Web Service.
> >>
> >> I tested on an aspx page, which is the *usual* type of "web application",
> >> which is all you mentioned in your original post, so, yes, it does make for
> >> "slightly different" testing conditions.
> >>
> >> Post webservice.asmx so we can dissect the code in it.
> >> It dosn't have earth-shaking super-secret code in it, does it ?
> >>
> >>
> >>
> >>
> >> Juan T. Llibre, asp.net MVP
> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> asp.net faq : http://asp.net.do/faq/
> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> ===================================
> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> news:BB12EEBF-1CEE-46D3-978C-AC47FA0D7CE9@.microsoft.com...
> >> > Maybe I did a test sligthly different?
> >> >> > I Wasn't in debug mode.
> >> >> > In the first test, I tried opening IE and writing directly a path like this:
> >> > http:\\localhost\Projects\2006\myapp\WebService.as mx
> >> > (I use a WebService for the test: when invoked, it returns the path of a
> >> > virtual directory, generated via Server.Mappath).
> >> > This test works correctly!
> >> >> > In the second test, I tried opening IE and writing directly a path like this:
> >> > http:\\localhost:1263\myapp\WebService.asmx
> >> > (in this way I use Cassini, it's right?).
> >> > In this test the problem happens!
> >> >> > I made some error?
> >> > --
> >> > Lorenzo
> >>
> >>
> >> > "Juan T. Llibre" ha scritto:
> >> >> >> Actually, I did quite a bit of testing with IIS after I read your post.
> >> >> It happens with IIS and I can repro it.
> >> >>
> >> >> You are mistaken about it only happening with Cassini.
> >> >> File the bug or, if you are not up to it, I will.
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Juan T. Llibre, asp.net MVP
> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> >> asp.net faq : http://asp.net.do/faq/
> >> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> >> ===================================
> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> >> news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
> >> >> > No, it happens only with Cassini, I just verified it!
> >> >> > --
> >> >> > Lorenzo
> >> >>
> >> >>
> >> >> > "Juan T. Llibre" ha scritto:
> >> >> >> >> >> Yes, please bug it as happening under IIS, too.
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> Juan T. Llibre, asp.net MVP
> >> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> >> >> asp.net faq : http://asp.net.do/faq/
> >> >> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> >> >> ===================================
> >> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> >> >> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
> >> >> >> > The bug was already reported!
> >> >> >> >> >> >> > (see:
> >> >> >> > http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
> >> >> >> > )
> >> >> >> >> >> >> > Reading the answer i realized that this happens only in debug mode, due to
> >> >> >> > the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
> >> >> >> > Cassini!
> >> >> >> > Lorenzo
> >> >> >>
> >> >> >>
> >> >> >> > "Juan T. Llibre" ha scritto:
> >> >> >> >> >> >> >> Good catch, Lorenzo.
> >> >> >> >>
> >> >> >> >> The behavior is as you describe it, and I agree that Server.MapPath should
> >> >> >> >> reflect the true physical directory of a virtual directory within an Application.
> >> >> >> >>
> >> >> >> >> Please go to the Product Feedback Center :
> >> >> >> >> http://lab.msdn.microsoft.com/produ...ck/default.aspx
> >> >> >> >> and file a bug for that behavior.
> >> >> >> >>
> >> >> >> >> You will need a Passport account to file a bug at the Feedback Center.
> >> >> >> >>
> >> >> >> >> Thank you!
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> Juan T. Llibre, asp.net MVP
> >> >> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
> >> >> >> >> asp.net faq : http://asp.net.do/faq/
> >> >> >> >> foros de asp.net, en espa?ol : http://asp.net.do/foros/
> >> >> >> >> ===================================
> >> >> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
> >> >> >> >> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
> >> >> >> >> > Hello,
> >> >> >> >> >> >> >> >> > I have a web application with a virtual directory in it. With 'virtual
> >> >> >> >> > directory' i mean
> >> >> >> >> > a folder whose physical path is different from the physical path of the
> >> >> >> >> > application, but in which Web Sharing is active.
> >> >> >> >> > For example:
> >> >> >> >> > my application is in "C:\Inetpub\wwwroot\MyApp",
> >> >> >> >> > the Virtual folder is in "C:\VirtualFolder",
> >> >> >> >> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
> >> >> >> >> >> >> >> >> > How can I get, from code, the real physical path of the virtual folder?
> >> >> >> >> > I tried with Server.Mappath, but I found that it returns
> >> >> >> >> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
> >> >> >> >> >> >> >> >> > Thanks
> >> >> >> >> > Lorenzo
> >> >> >> >> >> >> >> >> > --
> >> >> >> >> > Lorenzo
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
> .
That's why it's a bug!

Please file a bug report at :

http://lab.msdn.microsoft.com/produ...ck/default.aspx

Make sure that you point out the differences with the similar bug reported already :

http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
news:D1347A6F-60A9-4954-81E3-2AD27D4DBF49@.microsoft.com...
> This isn't a correct test to try: if I write "/Prova", it searches a folder
> directly in my localhost root, not in the current web application!
> You can try by yourself. Notice the different behavior of Cassini and IIS:
> IIS returns
> "C:\Inetpub\wwwroot\Prova", Cassini raises an error!
> By
> --
> Lorenzo
>
> "Juan T. Llibre" ha scritto:
>> Try, if "Prova" is a virtual directory/application :
>>
>> Server.MapPath("/Prova")
>>
>> Notice the slash...
>>
>>
>>
>> Juan T. Llibre, asp.net MVP
>> aspnetfaq.com : http://www.aspnetfaq.com/
>> asp.net faq : http://asp.net.do/faq/
>> foros de asp.net, en espaol : http://asp.net.do/foros/
>> ===================================
>> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> news:A68BE1E2-6252-443E-BBEE-E7A328542458@.microsoft.com...
>> >I tested the same thing with a webpage:
>> > the problem was identical, as I supposed.
>>> > The code to reproduce the test is quite simple:
>>> > Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> > System.EventArgs)Handles Me.Load
>> > Label2.Text = Server.MapPath("Prova")
>> > End Sub
>>> > (where Label2 is a Label Webcontrol and "Prova" is the virtual directory)
>>>> > The result is correct if, in IE, I reach the page using this address:
>> > http:\\localhost\Projects\2006\myapp\default2.aspx
>> > (so using IIS)
>>> > The result is wrong if, in IE, I reach the page using this address:
>> > http:\\localhost:1263\myapp\default2.aspx
>> > (so using Cassini)
>>> > With the webservice, the code was:
>>> > <WebMethod()> _
>> > Public Function AbsoluteEventsPath() As String
>> > Return Server.MapPath("Prova")
>> > End Function
>>>> > In my opinion, this is exactly the situation described in the filed bug, and
>> > it's due to a 'limitation' of Cassini that does not behave like IIS.
>> > (Luckily, this is not a big deal for me, because in the production server I
>> > use IIS).
>>> > If you went deeper than me and found a different situation, file it by
>> > yourself, and please notify it to me, that I am very curoius!
>>> > (my e-mail is lorenzoaaa@.REMOVE_MEtiscali.it)
>>> > Bye
>> > Lorenzo
>>> > --
>> > Lorenzo
>>>> > "Juan T. Llibre" ha scritto:
>>> >> You never mentioned that you were talking about a Web Service.
>> >>
>> >> I tested on an aspx page, which is the *usual* type of "web application",
>> >> which is all you mentioned in your original post, so, yes, it does make for
>> >> "slightly different" testing conditions.
>> >>
>> >> Post webservice.asmx so we can dissect the code in it.
>> >> It dosn't have earth-shaking super-secret code in it, does it ?
>> >>
>> >>
>> >>
>> >>
>> >> Juan T. Llibre, asp.net MVP
>> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> asp.net faq : http://asp.net.do/faq/
>> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> ===================================
>> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> news:BB12EEBF-1CEE-46D3-978C-AC47FA0D7CE9@.microsoft.com...
>> >> > Maybe I did a test sligthly different?
>> >>> >> > I Wasn't in debug mode.
>> >>> >> > In the first test, I tried opening IE and writing directly a path like this:
>> >> > http:\\localhost\Projects\2006\myapp\WebService.as mx
>> >> > (I use a WebService for the test: when invoked, it returns the path of a
>> >> > virtual directory, generated via Server.Mappath).
>> >> > This test works correctly!
>> >>> >> > In the second test, I tried opening IE and writing directly a path like this:
>> >> > http:\\localhost:1263\myapp\WebService.asmx
>> >> > (in this way I use Cassini, it's right?).
>> >> > In this test the problem happens!
>> >>> >> > I made some error?
>> >> > --
>> >> > Lorenzo
>> >>
>> >>
>> >> > "Juan T. Llibre" ha scritto:
>> >>> >> >> Actually, I did quite a bit of testing with IIS after I read your post.
>> >> >> It happens with IIS and I can repro it.
>> >> >>
>> >> >> You are mistaken about it only happening with Cassini.
>> >> >> File the bug or, if you are not up to it, I will.
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> Juan T. Llibre, asp.net MVP
>> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> >> asp.net faq : http://asp.net.do/faq/
>> >> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> >> ===================================
>> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> >> news:7F193410-480A-412C-850D-311C53C23B0F@.microsoft.com...
>> >> >> > No, it happens only with Cassini, I just verified it!
>> >> >> > --
>> >> >> > Lorenzo
>> >> >>
>> >> >>
>> >> >> > "Juan T. Llibre" ha scritto:
>> >> >>> >> >> >> Yes, please bug it as happening under IIS, too.
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> Juan T. Llibre, asp.net MVP
>> >> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> >> >> asp.net faq : http://asp.net.do/faq/
>> >> >> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> >> >> ===================================
>> >> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> >> >> news:984E00A5-2CCB-4A8B-8FCD-870B9DAAC94B@.microsoft.com...
>> >> >> >> > The bug was already reported!
>> >> >> >>> >> >> >> > (see:
>> >> >> >> > http://lab.msdn.microsoft.com/produ...09-b8fb08d7cbd8
>> >> >> >> > )
>> >> >> >>> >> >> >> > Reading the answer i realized that this happens only in debug mode, due to
>> >> >> >> > the use, by VS2005, of Cassini; so I can fix it attaching to IIS instead of
>> >> >> >> > Cassini!
>> >> >> >> > Lorenzo
>> >> >> >>
>> >> >> >>
>> >> >> >> > "Juan T. Llibre" ha scritto:
>> >> >> >>> >> >> >> >> Good catch, Lorenzo.
>> >> >> >> >>
>> >> >> >> >> The behavior is as you describe it, and I agree that Server.MapPath should
>> >> >> >> >> reflect the true physical directory of a virtual directory within an Application.
>> >> >> >> >>
>> >> >> >> >> Please go to the Product Feedback Center :
>> >> >> >> >> http://lab.msdn.microsoft.com/produ...ck/default.aspx
>> >> >> >> >> and file a bug for that behavior.
>> >> >> >> >>
>> >> >> >> >> You will need a Passport account to file a bug at the Feedback Center.
>> >> >> >> >>
>> >> >> >> >> Thank you!
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> Juan T. Llibre, asp.net MVP
>> >> >> >> >> aspnetfaq.com : http://www.aspnetfaq.com/
>> >> >> >> >> asp.net faq : http://asp.net.do/faq/
>> >> >> >> >> foros de asp.net, en espaol : http://asp.net.do/foros/
>> >> >> >> >> ===================================
>> >> >> >> >> "Lorenzo" <Lorenzo@.discussions.microsoft.com> wrote in message
>> >> >> >> >> news:7A8826EF-57CC-4474-A6B1-010E00B3CD70@.microsoft.com...
>> >> >> >> >> > Hello,
>> >> >> >> >>> >> >> >> >> > I have a web application with a virtual directory in it. With 'virtual
>> >> >> >> >> > directory' i mean
>> >> >> >> >> > a folder whose physical path is different from the physical path of the
>> >> >> >> >> > application, but in which Web Sharing is active.
>> >> >> >> >> > For example:
>> >> >> >> >> > my application is in "C:\Inetpub\wwwroot\MyApp",
>> >> >> >> >> > the Virtual folder is in "C:\VirtualFolder",
>> >> >> >> >> > and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
>> >> >> >> >>> >> >> >> >> > How can I get, from code, the real physical path of the virtual folder?
>> >> >> >> >> > I tried with Server.Mappath, but I found that it returns
>> >> >> >> >> > "C:\Inetpub\wwwroot\MyApp\VirtualFolder", not "C:\VirtualFolder"
>> >> >> >> >>> >> >> >> >> > Thanks
>> >> >> >> >> > Lorenzo
>> >> >> >> >>> >> >> >> >> > --
>> >> >> >> >> > Lorenzo
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>> .
>