设置 img 基本身份验证的凭据
我正在 VS2010 中开发一个内部 .Net 应用程序,以便在我公司的 Intranet 中部署。该站点使用 Windows 身份验证,以便用户在成功通过域身份验证后无需登录。对于一个页面,需要我从内网上获取一些信息,包括照片和其他信息。对于员工照片,我使用一个控件:
<asp:Image ID="imgPhoto" Style="display: inline-block" runat="server" CssClass="EmployeePhoto"
alt="Photo not available" />
从后端,这允许我通过更改照片 url 来根据用户选择来更改显示的照片,如下所示:
imgPhoto.ImageUrl = string.Format("http://{0}/{1}.jpg", MySitePath, employeePhotoPath);
但是路径受密码保护。有没有办法明确提供用于访问 asp:image 的凭据,以便我可以传入当前经过身份验证的用户的凭据,而不提示用户进行身份验证?
更新
曾经有一种方法可以将用户名+密码指定到 img 标签中,例如:
<img src="http://username:password@server/photos/1.jpg">
或类似的内容。这样凭证就可以访问该目录了吗?现在这有可能吗?
I am developing a internal .Net application in VS2010 for deployment within my company's intranet. The site uses Windows Authentication so that users do not have to log in when they are successfully authenticated to the domain. For one page, it is required that I get some information from the intranet including photos and other information. For the employee photo, I am using a control:
<asp:Image ID="imgPhoto" Style="display: inline-block" runat="server" CssClass="EmployeePhoto"
alt="Photo not available" />
From the back end, this allows me to change which photo is displayed depending on user choices by changing the photo url as follows:
imgPhoto.ImageUrl = string.Format("http://{0}/{1}.jpg", MySitePath, employeePhotoPath);
The path is password protected however.Is there any way to explicitly provide the credentials used to access the asp:image so that I can pass in the credentials of the current authenticated user without the user being prompted to authenticate?
UPDATE
There used to be a way to specify the username + password into the img tag like:
<img src="http://username:password@server/photos/1.jpg">
or something similar. So that the credentials are available to access the directory? Is this possible in any way now?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看:
http://www.1stbyte.com/2008/03/15/automatic-windows-authentication-with-firefox-networkautomatic-ntlm-authtrusted-uris/
或者,如果您想要插件来管理:
https://addons.mozilla.org/en- US/firefox/addon/integrated-auth-for-firefox/
See:
http://www.1stbyte.com/2008/03/15/automatic-windows-authentication-with-firefox-networkautomatic-ntlm-authtrusted-uris/
or, if you want an addon to manage that:
https://addons.mozilla.org/en-US/firefox/addon/integrated-auth-for-firefox/
我最终使用 WebClient 类设置凭据以向其他服务器进行身份验证,然后在本地下载照片:
之后,我引用了服务器上照片的本地副本:
这解决了我遇到的身份验证问题图像。
I ended up using the WebClient class to set the credentials to authenticate to the other server and then download the photo locally:
After that, I referenced the local copy of the photo on the server:
This got around the authentication problems I was running into with the image.