0
static public byte[] GetUrl(string url)
   {  byte[] buf;
        try
        {
             WebProxy myProxy = new WebProxy();
           IWebRequestCreate req = (IWebRequestCreate)WebRequest.Create(url);
           //WebRequest reqw = WebRequest.Create(req);
            WebResponse response = req.GetResponse();
            stream = response.GetResponseStream();

            using (BinaryReader br = new BinaryReader(stream))
            {

                int len = (int)(response.ContentLength);

                buf = br.ReadBytes(len);

                br.Close();
            }

            stream.Close();

            response.Close();
        }
        catch (Exception exp)
        {

            buf = null;
        }

        return (buf);   }

Here url="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOYAAAC+CAIAAACu1eR2A" like that. How to pass url IWebRequestCreate and get response ? please let you know . Its very useful for my project.

Here the url is in

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOYAAAC+CAIAAACu1eR2A"

is not accepted . So if i am going to replace data into http or https it throws an error the url is not identified. What to do?

divikdiya
  • 313
  • 3
  • 5
  • 14
  • That isn't a URL you need to fetch - all the data is there within the URL itself. It's a data URL. While it *may* be possible to make the regular `WebRequest` infrastructure handle it, it's probably simpler to look for a scheme of "data:" and handle it yourself. – Jon Skeet May 17 '18 at 09:59
  • The data is *embedded* in that URL. There's nothing to retrieve from elsewhere. And (side note), you *cannot* interchange schemes for a URL and expect it to make sense. There's no guarantee that two URLs which are identical except for `http:` or `https:` lead to the same resource, *let alone* what you attempted in your edit. – Damien_The_Unbeliever May 17 '18 at 12:09

0 Answers0