server.mappath和网络共享 [英] server.mappath and network shares

查看:84
本文介绍了server.mappath和网络共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的IIS网站有一个名为内容的虚拟目录映射到网络

共享。如果网站的主目录是c:\inetpub \ www.root并且

虚拟目录映射到网络共享\\ myserver \ content,

Server.MapPath返回c:\inetpub \ www.root \ content,而不是

\\ myserver \ content。


我' '尝试添加

< identity impersonate =" true"的userName = QUOT;名称"密码="密码" />


到web.config文件,以确保帐户的身份

访问网络资源是否合适权利,但这并没有改变MapPath返回的路径。


有谁知道什么是错的?


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?


推荐答案

这是因为Server.MapPath对IIS的MetaData以及实际路径所在的位置一无所知。您要么必须将其硬编码为UNC路径,要么创建一些实用程序来读取IIS的MetaData以获取实际的物理位置。


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

我的IIS网站有一个名为内容的虚拟目录映射到网络

共享。如果网站的主目录是c:\inetpub \ www.root并且

虚拟目录映射到网络共享\\ myserver \ content,

Server.MapPath返回c:\inetpub \ www.root \ content,而不是

\\ myserver \ content。


我' '尝试添加

< identity impersonate =" true"的userName = QUOT;名称"密码="密码" />


到web.config文件,以确保帐户的身份

访问网络资源是否合适权利,但这并没有改变MapPath返回的路径。


有谁知道什么是错的?

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?


但是将虚拟路径转换为物理路径正是mappath

应该做的事情。它确实适用于本地文件,这需要阅读元数据。


我已经看到该组上的其他帖子表明它确实有效我想要的方式

对某些人来说。


-Jay


" Matt Hawley" <!!mhawley @ N 2 O 4 S P A m.integrityts.com>!;在消息中写道

新闻:OG **************** @ TK2MSFTNGP11.phx.gbl ...
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:OG****************@TK2MSFTNGP11.phx.gbl...
那是因为Server.MapPath对IIS的MetaData
以及实际路径所在的位置一无所知。您要么必须将其作为UNC路径进行硬编码,要么创建一些实用程序来读取IIS的MetaData

以获得实际的物理位置。
Matt Hawley,MCAD .NET
http://www.eworldui。 net

我的IIS网站有一个名为content的虚拟目录映射到
网络共享。如果网站的主目录是c:\inetpub\wwwroot和
,则虚拟目录映射到网络共享\\ myserver \ content,
Server.MapPath将返回c: \inetpub \wwwroot \ content,而不是
\\myserver \ content。

我试过添加
< identity impersonate =" true" ;的userName = QUOT;名称"密码="密码" />

到web.config文件,以确保访问网络资源的帐户的身份具有适当的权限,但这不是
改变MapPath返回的路径。

有谁知道什么是错的?

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?



你好周杰伦,


感谢您的跟进。关于这个问题,我已经在我这边做了一般测试

,发现Server.MapPath确实返回了

远程服务器的UNCPath(其中asp .net文件和assemlby实际上找到了)。这里

是我测试的详细环境信息:

1.远程共享机:安装了.net framework1.1的Win2k服务器

分享一个文件夹作为某个Web应用程序的根文件夹。


2.服务器主机(在IIS中托管web应用程序):WinXP

Professional with。 net framework1.1已安装。并且这两台机器在同一个域中的
所以当在XP盒子上创建虚拟目录时,我将
粘贴某个UNC路径(\\servername \ sharedfoldername)然后选择

a DomainAccount,它们都是两台机器的管理员。然后,当我访问网页应用程序中的页面时,页面中包含以下代码:

Page_Load:

Response.Write(" ;< br>" + Server.MapPath(""));


然后,输出显示WIN2K上的某个UNC路径

mathine((\\servername \ sharedfoldername)而不是WINXP BOX上的物理路径。我也尝试了相反的方法(在XP盒子上共享一个文件夹) />
并在WIN2K机器上托管IIS虚拟目录,在访问UNC文件夹时仍然使用

DomainAccount
IIS管理器中的



所以我想你可能会检查我列出的上述步骤,看看他们是否可以提供任何线索。另外,我建议你也执行这样的

测试你身边是否有效。谢谢。


问候,


Steven Cheng

Microsoft在线支持


获取Secu re! www.microsoft.com/security

(此帖子按原样提供,不作任何保证,并且不授予

权利。)


在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



这篇关于server.mappath和网络共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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