Background: If you cannot directly access the server where the picture is saved, we can first make an ASPX page to accept the image sent by the server, and then the HTML page requests the ASPX page. For the image server to play a certain buffer protection, to prevent damage to the hacker attack.
Note: It is not possible to set the ImageUrl of a picture control directly in an ASPX page, this method has been experimentally unsuccessful.
1. showpic.aspx page
<%@ Page Language="C #"AutoEventWireup="true"codebehind="Showpic.aspx.cs"Inherits="Newproject.showpic" %>
2. Showpic.aspx.cs Background Code
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Web.UI;usingSystem.IO;usingSystem.Web.UI.WebControls;usingSystem.Net;namespacenewproject{ Public Partial classShowpic:System.Web.UI.Page {protected voidPage_Load (Objectsender, EventArgs e) { //Image.imageurl = "Http://local/v1/tfs/T1.ysssTByYT1RCvBVdK"; stringURL ="Http://local/v1/tfs/T1.ysefsefsefvBVdK"; stringContenttype="application/x-www-form-urlencoded"; Stream Reqstream=Sendgetrequestforstream (Url,contenttype); MemoryStream Ms=NewMemoryStream (); Reqstream.copyto (MS); //Response.Write (Ms. ToArray ());//This method is wrongResponse.BinaryWrite (Ms. ToArray ());//can be//HttpContext.Current.Response.BinaryWrite (Ms. ToArray ());//can be } PrivateStream SendGetRequest1 (stringURL) { stringcontent; HttpRequest request;//enables ASP. NET to read the HTTP values sent by a client during a WEB request.WebRequest WebRequest;//makes a request to a Uniform Resource Identifier (URI). this was an abstractHttpWebRequest HttpWebRequest;//provides an http-specific implementation of the System.Net.WebRequest class.HttpWebResponse HttpWebResponse; //string url = "FSEFSF";HttpWebRequest = webrequest.create (URL) asHttpWebRequest; HttpWebRequest.AllowAutoRedirect=true; Httpwebrequest.method="GET"; Httpwebrequest.contenttype="application/x-www-form-urlencoded"; //HttpWebRequest. ContentType = "Application/json"; //HttpWebRequest. ContentType = "Application/xml"; //HttpWebRequest. Headers.add ("url", url);HttpWebResponse= HttpWebRequest.GetResponse () asHttpWebResponse; Stream Resstream=Httpwebresponse.getresponsestream (); using(StreamReader sr =NewStreamReader (Resstream)) {Content=Sr. ReadToEnd (); } returnResstream; }}}
3. pic.html page
<!DOCTYPE HTML><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head> <title></title></Head><Body> <Div> <imgsrc= "Showpic.aspx"alt= "Alternate Text" /> </Div></Body></HTML>
The ASPX page picture is used as the URL to the IMG in HTML