Server.Mappath和虚拟目录 [英] Server.Mappath and Virtual Directories

查看:80
本文介绍了Server.Mappath和虚拟目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我有一个带有虚拟目录的Web应用程序。使用''虚拟

目录''我的意思是

a文件夹,其物理路径与

应用程序的物理路径不同,但是其中网络共享处于活动状态。

例如:

我的应用程序位于C:\Inetpub \wwwroot \ MyApp中,

虚拟文件夹位于C:\ VirtualBuilder中,

,IIS将其视为C:\Inetpub \wwwroot \ MyApp \ VirtualFolder。


如何从代码中获取虚拟文件夹的真实物理路径?

我尝试使用Server.Mappath,但我发现它返回

" C:\Inetpub \ www.root \ MyApp \ VirtualFolder",而不是C:\ VirtualBolder"


谢谢

Lorenzo


-

Lorenzo

解决方案

好的捕获,Lorenzo。


行为就像你描述的那样,我同意hat.ServerPath应该

反映应用程序中虚拟目录的真实物理目录。


请转到产品反馈中心:
http://lab.msdn.microsoft.com/produc ... k / default.aspx

并提出该行为的错误。


您需要一个Passport帐户才能在反馈中提交错误中心。


谢谢!


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/

============================= ======

Lorenz O" <螺***** @ discussions.microsoft.com>在消息中写道

新闻:7A ********************************** @ microsof t.com ...

您好,

我有一个带有虚拟目录的Web应用程序。使用''虚拟
目录''我的意思是
一个文件夹,其物理路径与
应用程序的物理路径不同,但Web共享处于活动状态。
例如:
我的应用程序位于C:\ Inetpub \wwwroot \ MyApp中,
虚拟文件夹位于C:\ VirtualBolder,
并且IIS看到它好像它在C:\Inetpub \wwwroot \ MyApp \ VirtualFolder中。

如何从代码中获取虚拟文件夹的真实物理路径?C:\ Inetpub \wwwroot \ MyApp \ VirtualFolder,而不是C:\ VirtualBuilder

谢谢
Lorenzo

Lorenzo



谢谢你的回答:我肯定会报告''虫''。


在此期间,你(或其他人)可以建议我另一种方式吗

同样的事情,还是变通方法?


谢谢

-

Lorenzo

" ; Juan T. Llibre ha scritto:

好抓,Lorenzo。

行为就像你描述的那样,我同意Server.MapPath应该反映应用程序中虚拟目录的真实物理目录。

请转到产品反馈中心:
http://lab.msdn.microsoft.com/produc...k/default.aspx
并提交一个bug行为。

您需要一个Passport帐户才能在反馈中心提交错误。

谢谢!

Juan T. Llibre,asp .net MVP
aspnetfaq.com: http://www.aspnetfaq.com/
asp.net常见问题: http://asp.net.do/ faq /
foros de asp.net,en espa?±ol: HTTP://asp.n et.do/foros/
=================================== < br> Lorenzo" <螺***** @ discussions.microsoft.com>在消息中写道
新闻:7A ********************************** @ microsof t.com。 ..

您好,

我有一个带有虚拟目录的Web应用程序。使用''虚拟
目录''我的意思是
一个文件夹,其物理路径与
应用程序的物理路径不同,但Web共享处于活动状态。
例如:
我的应用程序位于C:\ Inetpub \wwwroot \ MyApp中,
虚拟文件夹位于C:\ VirtualBolder,
并且IIS看到它好像它在C:\Inetpub \wwwroot \ MyApp \ VirtualFolder中。

如何从代码中获取虚拟文件夹的真实物理路径?C:\ Inetpub \wwwroot \ MyApp \ VirtualFolder,而不是C:\ VirtualBuilder

谢谢
Lorenzo

- Lorenzo




< blockquote>已经报告了这个bug!


(参见:
http://lab.msdn.microsoft.com/produc...9-b8fb08d7cbd8




阅读答案我意识到这只发生在调试模式下,因为VS2005使用的是Cassini的
;所以我可以修复它附加到IIS而不是

卡西尼!


-

Lorenzo

Juan T. Llibre ha scritto:

好抓,Lorenzo。

行为就像你描述的那样,我同意Server.MapPath应该反映应用程序中虚拟目录的真实物理目录。

请转到产品反馈中心:
http://lab.msdn.microsoft.com/produc...k/default.aspx
并提交一个bug行为。

您需要一个Passport帐户才能在反馈中心提交错误。

谢谢!

Juan T. Llibre,asp .net MVP
aspnetfaq.com: http://www.aspnetfaq.com/
asp.net常见问题: http://asp.net.do/ faq /
foros de asp.net,en espa?±ol: HTTP://asp.n et.do/foros/
=================================== < br> Lorenzo" <螺***** @ discussions.microsoft.com>在消息中写道
新闻:7A ********************************** @ microsof t.com。 ..

您好,

我有一个带有虚拟目录的Web应用程序。使用''虚拟
目录''我的意思是
一个文件夹,其物理路径与
应用程序的物理路径不同,但Web共享处于活动状态。
例如:
我的应用程序位于C:\ Inetpub \wwwroot \ MyApp中,
虚拟文件夹位于C:\ VirtualBolder,
并且IIS看到它好像它在C:\Inetpub \wwwroot \ MyApp \ VirtualFolder中。

如何从代码中获取虚拟文件夹的真实物理路径?C:\ Inetpub \wwwroot \ MyApp \ VirtualFolder,而不是C:\ VirtualBuilder

谢谢
Lorenzo

- Lorenzo




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

解决方案

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/produc...k/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" <Lo*****@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.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/produc...k/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" <Lo*****@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.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/produc...9-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/produc...k/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" <Lo*****@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.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




这篇关于Server.Mappath和虚拟目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆