You can use the file stream reading method to display images on a remote website, which is used to solve the problem where the remote website is an HTTPS address and the certificate is invalid.
Image stream acquisition:
1 <%@ WebHandler Language="C#" Class="ImageView" %> 2 3 using System.Drawing; 4 using System.IO; 5 using System.Net; 6 using System.Web; 7 8 public class ImageView : IHttpHandler 9 {10 public void ProcessRequest(HttpContext context)11 {12 string url = context.Server.UrlDecode(context.Request.QueryString["url"]);13 if (!string.IsNullOrEmpty(url))14 {15 WebRequest request = WebRequest.Create(url);16 Stream stream = request.GetResponse().GetResponseStream();17 if (stream != null)18 {19 var image = new Bitmap(stream);20 var ms = new MemoryStream();21 image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);22 23 context.Response.ContentType = "image/jpeg";24 context.Response.BinaryWrite(ms.ToArray());25 context.Response.End();26 }27 }28 }29 30 public bool IsReusable31 {32 get33 {34 return false;35 }36 }37 }
Image Display:
1 <! Doctype HTML> 2 <HTML xmlns = "http://www.w3.org/1999/xhtml"> 3