ASP.Net Web 处理程序 UNC 与文件路径
我有一个 Web 处理程序,用于读取文件,然后将其流式传输到客户端。如果我使用本地驱动器上的文件路径,则效果很好: D:\Path\To\My\File.flv
如果我使用共享名,但是: \ServerName\ShareName\File.flv
我收到“登录失败:未知的用户名或错误密码”。
共享对所有人开放,完全控制。
我已启用模拟并在处理程序中具有以下内容:
context.Response.Write("Context User: " + ((WindowsIdentity)context.User.Identity).Name + "<br />");
context.Response.Write("Windows Identity: " + WindowsIdentity.GetCurrent().Name + "<br />");
当我将 IIS 应用程序配置为使用特定帐户以匿名访问方式运行时,我得到以下
上下文用户: Windows 身份:SpecificAccount
当我将 IIS 配置为不使用匿名访问,而是使用 Windows 身份验证时,我得到
Context User: MyAccount Windows 身份:MyAccount
它不会更改共享与非共享的错误消息。
我找到了有关 Web 处理程序和模拟的网页: http://weblogs.asp.net/drnetjes/archive/2005 /06/06/410508.aspx
但是,我不确定如何实现它,或者它是否能解决问题。
有什么想法吗?
I have a Web Handler that I'm using to read a file and then stream it out to the client. This works fine if i use the file path on the local drive:
D:\Path\To\My\File.flv
If I use a sharename, however:
\ServerName\ShareName\File.flv
I get a "Logon failure: unknown user name or bad password."
The share is open to everyone, full control.
I have impersonation enabled and have the following in my handler:
context.Response.Write("Context User: " + ((WindowsIdentity)context.User.Identity).Name + "<br />");
context.Response.Write("Windows Identity: " + WindowsIdentity.GetCurrent().Name + "<br />");
When I configure the IIS application to run as with anonymous access using a specific account, I get the following
Context User:
Windows Identity: SpecificAccount
When I configure IIS to not use anonymous access, but use windows authentication, I get
Context User: MyAccount
Windows Identity: MyAccount
It does not change the error message for the share vs nonshare.
I find this webpage regarding Web Handlers and impersonation:
http://weblogs.asp.net/drnetjes/archive/2005/06/06/410508.aspx
but, I'm not exactly sure how to implement that, or, if it would even solve the issue.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您上面的帖子中,这很简单,但是您放置
\ServerName\ShareName\File.flv
不应该是
\\ServerName\ShareName\File.flv
最坏的情况,您可以使用
file://ServerName/ShareName/File.flv
,但请注意,对于本地文件,您应该使用简写file:///C:/path/File.flv< /代码>。 (请参阅维基百科)
In your above post, it's simple, but you put
\ServerName\ShareName\File.flv
shouldn't it be
\\ServerName\ShareName\File.flv
worst case, you can use
file://ServerName/ShareName/File.flv
, but note that for local files you should use the shorthandfile:///C:/path/File.flv
. (see wikipedia)啊...我讨厌回答自己的问题,但这就是问题所在:
共享和文件权限设置正确。这是一台旧的 Windows 2003 机器,当我使用新的应用程序池(我对这个特定的应用程序执行此操作)时,我总是遇到权限问题。
解决办法是(捂脸)重启服务器。
我对这 60 个人在这件事上浪费的所有脑细胞感到抱歉。
再次感谢您的所有帮助。
愚蠢的 IIS...愚蠢的 Windows 2003...有一天必须重建服务器
Gaah... I hate answering my own questions, but here's what the problem was:
The share and file permissions were set properly. This is an old windows 2003 machine and when I use a new application pool (which I did with this particular application), I always have a problem with permissions.
The solutions was (facepalm) reboot the server.
I'm sorry for all the braincells that the 60 some odd people wasted on this.
Thanks again for all your help.
Stupid IIS... Stupid Windows 2003... must rebuild server someday