[英]can we set ImageUrl to physical path?
I have a image control
and I have to set it's ImageUrl
to a physical path
like C:\\image\\image1.jpg
but control takes virtual path only. 我有一个image control
,我必须将其ImageUrl
设置为C:\\image\\image1.jpg
类的physical path
但控件仅采用虚拟路径。 How to show that image if path we have is physical path? 如果我们拥有的路径是物理路径,如何显示该图像?
You could create a Virtual Folder in IIS . 您可以在IIS中创建一个虚拟文件夹 。 You can then set your image control's path to be that of the Virtual Folder. 然后,您可以将图像控件的路径设置为虚拟文件夹的路径。
No because the client (browser) can't access that file. 否,因为客户端(浏览器)无法访问该文件。 It needs to be a file that is exposed to "the internet". 它必须是暴露于“互联网”的文件。 You will need to move the image elsewhere and reference it with the tilde ~
which means "application path": ~/Images/images1.jpg
. 您将需要将图像移动到其他位置,并使用代字号~
引用它,这表示“应用程序路径”: ~/Images/images1.jpg
。
您不能,该图像必须位于网络根目录中才能让最终用户看到它,因此它将具有虚拟路径。
You need a Proxy Object
. 您需要一个Proxy Object
。 This object should load the image from physical path as an server it when the page needs it. 当页面需要该对象时,该对象应将其作为服务器从物理路径加载为服务器。 It can be as simple as loading it to a static variable or a complex Lazy (load image on demand) proxy with file system watcher for tracking changes of images. 它可以简单地将其加载到静态变量或带有文件系统监视程序的复杂的Lazy(按需加载图像)代理以跟踪图像的变化。
It could be a control or web-service (maybe authentication is needed). 它可以是控件或Web服务(可能需要身份验证)。
Still the image has to be placed in local server root folder. 仍然必须将映像放置在本地服务器的根文件夹中。 Not a physical path. 不是物理路径。
No. We, as software developers, do not directly interact with the physical layer. 不。作为软件开发人员,我们不直接与物理层进行交互。 The physical layer is (usually) magnetic particles on a spinning platter. 物理层通常是旋转的磁盘上的磁性粒子。 There is no physical path to it. 没有物理路径。 We operate at several layers of abstraction above the physical layer. 我们在物理层之上的几个抽象层进行操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.