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:
>
Tuesday, March 13, 2012
Server.Mappath and Virtual Directories
Labels:
application,
asp,
directories,
directory,
folder,
meana,
net,
path,
physical,
servermappath,
virtual,
virtualdirectory,
web
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment