Server.MapPath返回错误的路径 [英] Server.MapPath returning wrong path

查看:150
本文介绍了Server.MapPath返回错误的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将目录f:\ Company [\\ Product]设置为web共享,因此它在我的测试服务器上的默认网站上有一个

虚拟目录''的IIS。如果我尝试使用
在该站点中使用Server.MapPath,它将返回

c:\ Inetpub \ www.root中的路径而不是真实路径。


有谁能告诉我为什么这不起作用?


问候,

John

解决方案

Server.MapPath使用默认网站的根作为本地文件夹的确定

。由于某些奇怪的原因,它实际上并没有看到单独的虚拟

目录......我认为这是一个错误。



John Rebbeck <乔** @ rebent.com>在消息中写道

新闻:在************** @ TK2MSFTNGP11.phx.gbl ...

我有目录f:\Company \Product设置为web共享,因此它在我的测试服务器的IIS上的默认网站上有一个
虚拟目录。如果我
尝试在该站点中使用Server.MapPath,它将返回一个路径,而不是真正的路径。

任何人都可以告诉我为什么不工作?

问候,
约翰



任何方式绕过它?


" Aaron Bertrand [MVP]" < AA *** @ TRASHaspfaq.com>在消息中写道

news:eW ************** @ tk2msftngp13.phx.gbl ...

Server.MapPath使用默认网站的根目录,确定本地文件夹的
。出于某种奇怪的原因,它实际上并没有看到单独的虚拟目录...我认为这是一个错误。


John Rebbeck <乔** @ rebent.com>在消息中写道
新闻:在************** @ TK2MSFTNGP11.phx.gbl ...

我有目录f: \ Produany \Product设置为web共享,因此它在我的测试服务器的IIS上的默认网站上有
a虚拟目录。如果我


尝试使用

在该站点中使用Server.MapPath,它将返回
c:\ Inetpub \ www.root中的路径而不是真实路径。

有谁能告诉我为什么这不起作用?

问候,
John




我不确定使用服务器变量

APPL_PHYSICAL_PATH产生了什么?


我认为语法是:

Response.Write Request.ServerVariables(" APPL_PHYSICAL_PATH")

要仔细检查,确认无误。

-


Phillip Windell [CCNA,MVP,MCP]
pw ****** @ wandtv.com

WAND-TV(ABC会员)
www.wandtv.com


" John Rebbeck" <乔** @ rebent.com>在消息中写道

新闻:#N ************** @ TK2MSFTNGP09.phx.gbl ...

任何获取方式在它附近?

Aaron Bertrand [MVP]" < AA *** @ TRASHaspfaq.com>在消息中写道
新闻:eW ************** @ tk2msftngp13.phx.gbl ...

Server.MapPath使用默认的根网站作为其
确定

本地文件夹。出于某种奇怪的原因,它实际上并没有看到单独的虚拟目录...我认为这是一个错误。


John Rebbeck <乔** @ rebent.com>在消息中写道
新闻:在************** @ TK2MSFTNGP11.phx.gbl ...

我有目录f: \ Produany \Product设置为web共享所以


它有

我的测试服务器上的默认网站中的虚拟目录



IIS。如果我尝试

在该站点中使用Server.MapPath,它将返回
c:\ Inetpub \ www.root中的路径而不是真实路径。

谁能告诉我为什么这不起作用?

问候,
John





I''ve got the directory f:\Company\Product set as web shared so it''s got a
virtual directory in the default web site on my test server''s IIS. If I try
to use Server.MapPath in that site it returns a path within
c:\Inetpub\wwwroot rather than the real path.

Can anyone please tell me why this isn''t working?

Regards,
John

解决方案

Server.MapPath uses the root of the default web site as its determination of
the local folder. It doesn''t actually look at individual virtual
directories, for some bizarre reason... I think it''s a bug.


"John Rebbeck" <jo**@rebent.com> wrote in message
news:On**************@TK2MSFTNGP11.phx.gbl...

I''ve got the directory f:\Company\Product set as web shared so it''s got a
virtual directory in the default web site on my test server''s IIS. If I try to use Server.MapPath in that site it returns a path within
c:\Inetpub\wwwroot rather than the real path.

Can anyone please tell me why this isn''t working?

Regards,
John



Any way to get around it?

"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:eW**************@tk2msftngp13.phx.gbl...

Server.MapPath uses the root of the default web site as its determination of the local folder. It doesn''t actually look at individual virtual
directories, for some bizarre reason... I think it''s a bug.


"John Rebbeck" <jo**@rebent.com> wrote in message
news:On**************@TK2MSFTNGP11.phx.gbl...

I''ve got the directory f:\Company\Product set as web shared so it''s got a virtual directory in the default web site on my test server''s IIS. If I


try

to use Server.MapPath in that site it returns a path within
c:\Inetpub\wwwroot rather than the real path.

Can anyone please tell me why this isn''t working?

Regards,
John




I''m not sure but what does using the Server Variable
APPL_PHYSICAL_PATH produce?

I think the syntax would be:
Response.Write Request.ServerVariables("APPL_PHYSICAL_PATH ")
Be double check that to be sure.
--

Phillip Windell [CCNA, MVP, MCP]
pw******@wandtv.com
WAND-TV (ABC Affiliate)
www.wandtv.com

"John Rebbeck" <jo**@rebent.com> wrote in message
news:#N**************@TK2MSFTNGP09.phx.gbl...

Any way to get around it?

"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:eW**************@tk2msftngp13.phx.gbl...

Server.MapPath uses the root of the default web site as its determination

of

the local folder. It doesn''t actually look at individual virtual
directories, for some bizarre reason... I think it''s a bug.


"John Rebbeck" <jo**@rebent.com> wrote in message
news:On**************@TK2MSFTNGP11.phx.gbl...

I''ve got the directory f:\Company\Product set as web shared so

it''s got

a virtual directory in the default web site on my test server''s


IIS. If I try

to use Server.MapPath in that site it returns a path within
c:\Inetpub\wwwroot rather than the real path.

Can anyone please tell me why this isn''t working?

Regards,
John





这篇关于Server.MapPath返回错误的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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