How to use the program to get the image address after the remote URL executes

Source: Internet
Author: User

Remote url:https://121.199.16.229:8890/generate.cgi?rbid=1001&esn=22021434025005&pic=png&count=1& Pix=250&cor=lo&comm=%e6%b5%a6%e6%b1%9f%e6%b8%b8%e8%a7%881%e5%8f%b7%e9%be%99%e8%88%b9%2f%e5%b7%a5%e8%a1 %8c%e5%8f%b7%ef%bc%8c2013%e5%b9%b46%e6%9c%881%e5%8f%b7%ef%bd%9e2013%e5%b9%b46%e6%9c%8831%e5%8f%b7%ef%bc%8c14% 3a00
After execution: A picture address such as Https://121.199.16.229:8890/cgi/1001313097265699.png is generated

How to get the URL of this image by accessing the remote URL inside the program

Reply:

HttpWebRequest set the autoredirection on it. It will automatically handle 301 jumps.

Add System.Net and System.Security two DLLs and introduce the appropriate namespaces.

Static voidMain (string[] args) {HttpWebRequest WebRequest= (HttpWebRequest) webrequest.create ("https://121.199.16.229:8890/generate.cgi?rbid=1001&esn=22021434025005&pic=png&count=1&pix= 250&cor=lo&comm=%e6%b5%a6%e6%b1%9f%e6%b8%b8%e8%a7%881%e5%8f%b7%e9%be%99%e8%88%b9%2f%e5%b7%a5%e8%a1%8c% E5%8f%b7%ef%bc%8c2013%e5%b9%b46%e6%9c%881%e5%8f%b7%ef%bd%9e2013%e5%b9%b46%e6%9c%8831%e5%8f%b7%ef%bc%8c14%3a00 "); Servicepointmanager.servercertificatevalidationcallback=NewSystem.Net.Security.RemoteCertificateValidationCallback (CheckValidationResult);//Verifying server certificate callbacks automatic validationWebResponse WebResponse =Webrequest.getresponse (); Console.WriteLine (WebResponse.ResponseUri.AbsoluteUri);//Output https://121.199.16.229:8890/cgi/1001363993292848.png        }          Public Static BOOLCheckValidationResult (Objectsender, X509Certificate certificate, X509chain chain, sslpolicyerrors errors) {   //Always accept            return true; }

How to use the program to get the image address after the remote URL executes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.