简体   繁体   English

通过 Url 从客户端访问 IIS 服务器上的图像 | ASP.NET

[英]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.

相关问题 IIS 8-通过ASP.NET在服务器上启动exe - IIS 8 - Launch exe on server via ASP.NET 通过IIS上的ASP.NET/C#在服务器上运行进程 - Running Process on Server via ASP.NET/C# on IIS 将文件从IIs6.0服务器复制到客户端计算机,而不在单击ASP.NET 3.5中的按钮时显示文件对话框窗口 - copy files from IIs6.0 server to client machine without showing file dialog window on click of button in ASP.NET 3.5 从客户端计算机到ASP.NET MVC中的服务器批量上传图像 - Bulk Image Upload from client machine to server in ASP.NET MVC 通过iTextSharp ASP.NET将二进制图像数据从SQL Server检索为pdf - Retrieve binary image data from SQL Server into pdf via iTextSharp ASP.NET 无法调整通过iTextSharp从SQL Server ASP.Net插入pdf的图像的大小 - Unable to resize image inserted into pdf from SQL server ASP.Net via iTextSharp 需要通过 GET 方法访问 URL,使用 C# ASP.NET Z98AD8B3C99B4CA16F1F7FA8EE4 - Need to access URL from GET method, using C# ASP.NET Blazor Server 从asp.net访问Domino服务器 - Access Domino Server from asp.net 从 ASP.NET MVC 客户端应用程序和 .NET 5 openiddict 服务器注销。 登出后重定向网址无效 - Logout from ASP.NET MVC client app and a .NET 5 openiddict server. Post logout redirect url invalid 毕加索未从ASP.NET Core Web API服务器上的URL加载图像 - Picasso is not loading Image from URL on ASP.NET Core Web API server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM