[英]Access image on IIS server from client via Url | ASP .Net
My application is an Api ASP.Net, and I save the images in the "wwwroot"
folder我的应用程序是 Api ASP.Net,我将图像保存在
"wwwroot"
文件夹中
Content内容
When I publish my application that structure is created as well and I want to access the images through a URL当我发布我的应用程序时,该结构也被创建并且我想通过 URL 访问图像
From Client Angular 2来自客户端 Angular 2
<img src="{{ 'http://192.168.1.20/Api/api/uploads/Koala.jpg'}} " >
(Not Found)
I must mention, that my application is published locally, and users connected to the network must access the images必须提一下,我的应用是在本地发布的,连接到网络的用户必须访问图像
Question问题
How to access the image found on the IIS server with the Url?如何使用 Url 访问 IIS 服务器上的图像? I am right?
我是对的? Correct me if I'm wrong Thank you all
如果我错了请纠正我谢谢大家
First try to access the image url on the browser ie,首先尝试在浏览器上访问图像 url 即,
http://localhost/Api/api/uploads/Koala.jpg http://localhost/Api/api/uploads/Koala.jpg
If it displays the image then there is not problem with you IIS hosting.如果它显示图像,那么您的 IIS 托管没有问题。
Now try the same url from a different machine in the network ie,现在从网络中的不同机器尝试相同的 url,即,
http://192.168.1.20/Api/api/uploads/Koala.jpg (from a different machine) http://192.168.1.20/Api/api/uploads/Koala.jpg (来自不同的机器)
If it does not work then make sure that you machine accepts http inbound traffic over the network.如果它不起作用,请确保您的机器接受 http 通过网络的入站流量。
Use tilde ~
for relative URL in paths :使用波浪号
~
表示路径中的相对 URL :
<img src="{{ '~/uploads/Koala.jpg'}} " >
Maybe <img id="Image" runat="server" src="~/Images/img.jpg" />
也许
<img id="Image" runat="server" src="~/Images/img.jpg" />
Based on my understanding, you shouldn't specify the full URL in <img src="{{ }}">.
根据我的理解,您不应该在
<img src="{{ }}">.
If you want to specify full URL in Src attribute, you don't need angular.如果要在 Src 属性中指定完整的 URL,则不需要 angular。 You should just remove
{{''}}
and modify the URL to您应该只删除
{{''}}
并将 URL 修改为
<img src="http://192.168.1.20/Api/api/uploads/Koala.jpg" >
If you want to use angular2 in this case, you should just modify the URL like如果你想在这种情况下使用 angular2,你应该修改 URL 像
<img src="{{imageUrl}}">
Then declare the variable imageUrl in Component.然后在 Component.xml 中声明变量imageUrl 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.