Who can download this image using .net 3.5












1















The struggle is real. Somehow I can't download this image



string url = @"https://valgfrigave.dk/image/cache/catalog/200%20kr./Lyngby-glas-whiskey01_1000X1000px_200kr-750x750.jpg";


The return error is



 The remote server returned an error: (404) Not Found.


But if you post the url into a browser, you'll get these whiskey glasses
enter image description here



I've been using WebClient and HttpWebRequest. Tried all of the suggestions an answers from



How do I programmatically save an image from a URL?



https://social.msdn.microsoft.com/Forums/en-US/d77b3c9a-d453-4622-8639-b7f0f91ecc9a/save-image-from-given-url?forum=csharpgeneral



https://forgetcode.com/CSharp/2052-Download-images-from-a-URL



https://www.codeproject.com/Articles/24920/C-Image-Download



https://social.msdn.microsoft.com/Forums/vstudio/en-US/c3289e1b-56aa-49b8-8c62-feaaf51cd0a2/download-images-from-url?forum=csharpgeneral



(...and alot more...)



But none of them is able to download the image.



EDIT



Below is the code where I try to download the image. The error occurs at client.OpenRead(innUri):



class Program
{
static void Main(string args)
{
string url = @"https://valgfrigave.dk/image/cache/catalog/200%20kr./Lyngby-glas-whiskey01_1000X1000px_200kr-750x750.jpg";
string fileFullPath = @"C:TEMPImage.jpg";

using (WebClient client = new WebClient())
{
Uri innUri = null;
Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);

try
{
client.Headers.Add("Accept-Language", "en-US");
client.Headers.Add("Accept-Encoding", "gzip, deflate");
client.Headers.Add("Accept", " text/html, application/xhtml+xml, */*");
client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");

using (Stream stream = client.OpenRead(innUri))
{
using (System.IO.FileStream output = new System.IO.FileStream(fileFullPath, FileMode.Create))
{
byte buffer = new byte[16 * 1024]; // Fairly arbitrary size
int bytesRead;

while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, bytesRead);
}
}
}
}
catch (WebException we)
{
throw we;
}
}
}
}


2nd EDIT



Still doesn't work after trying the suggested approach
enter image description here



SOLUTION



A solution has been found and can be seen by the comment from @Stephan Schlecht.
Added the following method and replaced the URI creation:



Method added:



public static Uri MyUri(string url)
{
Uri uri = new Uri(url);
System.Reflection.MethodInfo getSyntax = typeof(UriParser).GetMethod("GetSyntax", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
System.Reflection.FieldInfo flagsField = typeof(UriParser).GetField("m_Flags", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
if (getSyntax != null && flagsField != null)
{
foreach (string scheme in new { "http", "https" })
{
UriParser parser = (UriParser)getSyntax.Invoke(null, new object { scheme });
if (parser != null)
{
int flagsValue = (int)flagsField.GetValue(parser);
// Clear the CanonicalizeAsFilePath attribute
if ((flagsValue & 0x1000000) != 0)
flagsField.SetValue(parser, flagsValue & ~0x1000000);
}
}
}
uri = new Uri(url);
return uri;
}


Replaced my original code:



    Uri innUri = null;
Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);


with:



    //Uri innUri = null;
//Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);
Uri innUri = MyUri(url);









share|improve this question

























  • @Nkosi, try with Console App, NET 3.5 Apparently something is changed (fixed?) in the later NET Framework implementations

    – Ivan Stoev
    Dec 3 '18 at 10:34











  • @Nkosi Yes, it is. But something in NET 4.5 made this code works :)

    – Ivan Stoev
    Dec 3 '18 at 11:00











  • I don't think the code or the version is the problem, but the url itself. It seems that this part is the issue kr./, while this works fine https://valgfrigave.dk/image/cache/catalog/50%20kr/notesbog03_1000x1000px-228x228.jpg. Apparentlty dotnet cannot handle that dot in the url followed by a /.

    – VDWWD
    Dec 3 '18 at 11:32













  • @Ivan Stoev From .Net 4.0 and above,there has been some fixes which made it possible for the code to download the image. Created a simple console application with the code in my question and it works with .Net 4.0 and above, but not with 3.5 which is the framework I need to use since Axapta 2009 can't handle .Net 4.0

    – Phu Minh Pham
    Dec 3 '18 at 15:37






  • 1





    Both WebClient and HttpWebRequest internally use a Uri. When using NET 3.5, the dot character already gets removed when instantiating a Uri, whereas NET 4.5 leaves it as-is.

    – pfx
    Dec 3 '18 at 18:43
















1















The struggle is real. Somehow I can't download this image



string url = @"https://valgfrigave.dk/image/cache/catalog/200%20kr./Lyngby-glas-whiskey01_1000X1000px_200kr-750x750.jpg";


The return error is



 The remote server returned an error: (404) Not Found.


But if you post the url into a browser, you'll get these whiskey glasses
enter image description here



I've been using WebClient and HttpWebRequest. Tried all of the suggestions an answers from



How do I programmatically save an image from a URL?



https://social.msdn.microsoft.com/Forums/en-US/d77b3c9a-d453-4622-8639-b7f0f91ecc9a/save-image-from-given-url?forum=csharpgeneral



https://forgetcode.com/CSharp/2052-Download-images-from-a-URL



https://www.codeproject.com/Articles/24920/C-Image-Download



https://social.msdn.microsoft.com/Forums/vstudio/en-US/c3289e1b-56aa-49b8-8c62-feaaf51cd0a2/download-images-from-url?forum=csharpgeneral



(...and alot more...)



But none of them is able to download the image.



EDIT



Below is the code where I try to download the image. The error occurs at client.OpenRead(innUri):



class Program
{
static void Main(string args)
{
string url = @"https://valgfrigave.dk/image/cache/catalog/200%20kr./Lyngby-glas-whiskey01_1000X1000px_200kr-750x750.jpg";
string fileFullPath = @"C:TEMPImage.jpg";

using (WebClient client = new WebClient())
{
Uri innUri = null;
Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);

try
{
client.Headers.Add("Accept-Language", "en-US");
client.Headers.Add("Accept-Encoding", "gzip, deflate");
client.Headers.Add("Accept", " text/html, application/xhtml+xml, */*");
client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");

using (Stream stream = client.OpenRead(innUri))
{
using (System.IO.FileStream output = new System.IO.FileStream(fileFullPath, FileMode.Create))
{
byte buffer = new byte[16 * 1024]; // Fairly arbitrary size
int bytesRead;

while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, bytesRead);
}
}
}
}
catch (WebException we)
{
throw we;
}
}
}
}


2nd EDIT



Still doesn't work after trying the suggested approach
enter image description here



SOLUTION



A solution has been found and can be seen by the comment from @Stephan Schlecht.
Added the following method and replaced the URI creation:



Method added:



public static Uri MyUri(string url)
{
Uri uri = new Uri(url);
System.Reflection.MethodInfo getSyntax = typeof(UriParser).GetMethod("GetSyntax", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
System.Reflection.FieldInfo flagsField = typeof(UriParser).GetField("m_Flags", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
if (getSyntax != null && flagsField != null)
{
foreach (string scheme in new { "http", "https" })
{
UriParser parser = (UriParser)getSyntax.Invoke(null, new object { scheme });
if (parser != null)
{
int flagsValue = (int)flagsField.GetValue(parser);
// Clear the CanonicalizeAsFilePath attribute
if ((flagsValue & 0x1000000) != 0)
flagsField.SetValue(parser, flagsValue & ~0x1000000);
}
}
}
uri = new Uri(url);
return uri;
}


Replaced my original code:



    Uri innUri = null;
Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);


with:



    //Uri innUri = null;
//Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);
Uri innUri = MyUri(url);









share|improve this question

























  • @Nkosi, try with Console App, NET 3.5 Apparently something is changed (fixed?) in the later NET Framework implementations

    – Ivan Stoev
    Dec 3 '18 at 10:34











  • @Nkosi Yes, it is. But something in NET 4.5 made this code works :)

    – Ivan Stoev
    Dec 3 '18 at 11:00











  • I don't think the code or the version is the problem, but the url itself. It seems that this part is the issue kr./, while this works fine https://valgfrigave.dk/image/cache/catalog/50%20kr/notesbog03_1000x1000px-228x228.jpg. Apparentlty dotnet cannot handle that dot in the url followed by a /.

    – VDWWD
    Dec 3 '18 at 11:32













  • @Ivan Stoev From .Net 4.0 and above,there has been some fixes which made it possible for the code to download the image. Created a simple console application with the code in my question and it works with .Net 4.0 and above, but not with 3.5 which is the framework I need to use since Axapta 2009 can't handle .Net 4.0

    – Phu Minh Pham
    Dec 3 '18 at 15:37






  • 1





    Both WebClient and HttpWebRequest internally use a Uri. When using NET 3.5, the dot character already gets removed when instantiating a Uri, whereas NET 4.5 leaves it as-is.

    – pfx
    Dec 3 '18 at 18:43














1












1








1


0






The struggle is real. Somehow I can't download this image



string url = @"https://valgfrigave.dk/image/cache/catalog/200%20kr./Lyngby-glas-whiskey01_1000X1000px_200kr-750x750.jpg";


The return error is



 The remote server returned an error: (404) Not Found.


But if you post the url into a browser, you'll get these whiskey glasses
enter image description here



I've been using WebClient and HttpWebRequest. Tried all of the suggestions an answers from



How do I programmatically save an image from a URL?



https://social.msdn.microsoft.com/Forums/en-US/d77b3c9a-d453-4622-8639-b7f0f91ecc9a/save-image-from-given-url?forum=csharpgeneral



https://forgetcode.com/CSharp/2052-Download-images-from-a-URL



https://www.codeproject.com/Articles/24920/C-Image-Download



https://social.msdn.microsoft.com/Forums/vstudio/en-US/c3289e1b-56aa-49b8-8c62-feaaf51cd0a2/download-images-from-url?forum=csharpgeneral



(...and alot more...)



But none of them is able to download the image.



EDIT



Below is the code where I try to download the image. The error occurs at client.OpenRead(innUri):



class Program
{
static void Main(string args)
{
string url = @"https://valgfrigave.dk/image/cache/catalog/200%20kr./Lyngby-glas-whiskey01_1000X1000px_200kr-750x750.jpg";
string fileFullPath = @"C:TEMPImage.jpg";

using (WebClient client = new WebClient())
{
Uri innUri = null;
Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);

try
{
client.Headers.Add("Accept-Language", "en-US");
client.Headers.Add("Accept-Encoding", "gzip, deflate");
client.Headers.Add("Accept", " text/html, application/xhtml+xml, */*");
client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");

using (Stream stream = client.OpenRead(innUri))
{
using (System.IO.FileStream output = new System.IO.FileStream(fileFullPath, FileMode.Create))
{
byte buffer = new byte[16 * 1024]; // Fairly arbitrary size
int bytesRead;

while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, bytesRead);
}
}
}
}
catch (WebException we)
{
throw we;
}
}
}
}


2nd EDIT



Still doesn't work after trying the suggested approach
enter image description here



SOLUTION



A solution has been found and can be seen by the comment from @Stephan Schlecht.
Added the following method and replaced the URI creation:



Method added:



public static Uri MyUri(string url)
{
Uri uri = new Uri(url);
System.Reflection.MethodInfo getSyntax = typeof(UriParser).GetMethod("GetSyntax", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
System.Reflection.FieldInfo flagsField = typeof(UriParser).GetField("m_Flags", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
if (getSyntax != null && flagsField != null)
{
foreach (string scheme in new { "http", "https" })
{
UriParser parser = (UriParser)getSyntax.Invoke(null, new object { scheme });
if (parser != null)
{
int flagsValue = (int)flagsField.GetValue(parser);
// Clear the CanonicalizeAsFilePath attribute
if ((flagsValue & 0x1000000) != 0)
flagsField.SetValue(parser, flagsValue & ~0x1000000);
}
}
}
uri = new Uri(url);
return uri;
}


Replaced my original code:



    Uri innUri = null;
Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);


with:



    //Uri innUri = null;
//Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);
Uri innUri = MyUri(url);









share|improve this question
















The struggle is real. Somehow I can't download this image



string url = @"https://valgfrigave.dk/image/cache/catalog/200%20kr./Lyngby-glas-whiskey01_1000X1000px_200kr-750x750.jpg";


The return error is



 The remote server returned an error: (404) Not Found.


But if you post the url into a browser, you'll get these whiskey glasses
enter image description here



I've been using WebClient and HttpWebRequest. Tried all of the suggestions an answers from



How do I programmatically save an image from a URL?



https://social.msdn.microsoft.com/Forums/en-US/d77b3c9a-d453-4622-8639-b7f0f91ecc9a/save-image-from-given-url?forum=csharpgeneral



https://forgetcode.com/CSharp/2052-Download-images-from-a-URL



https://www.codeproject.com/Articles/24920/C-Image-Download



https://social.msdn.microsoft.com/Forums/vstudio/en-US/c3289e1b-56aa-49b8-8c62-feaaf51cd0a2/download-images-from-url?forum=csharpgeneral



(...and alot more...)



But none of them is able to download the image.



EDIT



Below is the code where I try to download the image. The error occurs at client.OpenRead(innUri):



class Program
{
static void Main(string args)
{
string url = @"https://valgfrigave.dk/image/cache/catalog/200%20kr./Lyngby-glas-whiskey01_1000X1000px_200kr-750x750.jpg";
string fileFullPath = @"C:TEMPImage.jpg";

using (WebClient client = new WebClient())
{
Uri innUri = null;
Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);

try
{
client.Headers.Add("Accept-Language", "en-US");
client.Headers.Add("Accept-Encoding", "gzip, deflate");
client.Headers.Add("Accept", " text/html, application/xhtml+xml, */*");
client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");

using (Stream stream = client.OpenRead(innUri))
{
using (System.IO.FileStream output = new System.IO.FileStream(fileFullPath, FileMode.Create))
{
byte buffer = new byte[16 * 1024]; // Fairly arbitrary size
int bytesRead;

while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, bytesRead);
}
}
}
}
catch (WebException we)
{
throw we;
}
}
}
}


2nd EDIT



Still doesn't work after trying the suggested approach
enter image description here



SOLUTION



A solution has been found and can be seen by the comment from @Stephan Schlecht.
Added the following method and replaced the URI creation:



Method added:



public static Uri MyUri(string url)
{
Uri uri = new Uri(url);
System.Reflection.MethodInfo getSyntax = typeof(UriParser).GetMethod("GetSyntax", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
System.Reflection.FieldInfo flagsField = typeof(UriParser).GetField("m_Flags", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
if (getSyntax != null && flagsField != null)
{
foreach (string scheme in new { "http", "https" })
{
UriParser parser = (UriParser)getSyntax.Invoke(null, new object { scheme });
if (parser != null)
{
int flagsValue = (int)flagsField.GetValue(parser);
// Clear the CanonicalizeAsFilePath attribute
if ((flagsValue & 0x1000000) != 0)
flagsField.SetValue(parser, flagsValue & ~0x1000000);
}
}
}
uri = new Uri(url);
return uri;
}


Replaced my original code:



    Uri innUri = null;
Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);


with:



    //Uri innUri = null;
//Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out innUri);
Uri innUri = MyUri(url);






c# .net url .net-3.5 webclient-download






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 4 '18 at 9:36







Phu Minh Pham

















asked Nov 20 '18 at 9:43









Phu Minh PhamPhu Minh Pham

37861533




37861533













  • @Nkosi, try with Console App, NET 3.5 Apparently something is changed (fixed?) in the later NET Framework implementations

    – Ivan Stoev
    Dec 3 '18 at 10:34











  • @Nkosi Yes, it is. But something in NET 4.5 made this code works :)

    – Ivan Stoev
    Dec 3 '18 at 11:00











  • I don't think the code or the version is the problem, but the url itself. It seems that this part is the issue kr./, while this works fine https://valgfrigave.dk/image/cache/catalog/50%20kr/notesbog03_1000x1000px-228x228.jpg. Apparentlty dotnet cannot handle that dot in the url followed by a /.

    – VDWWD
    Dec 3 '18 at 11:32













  • @Ivan Stoev From .Net 4.0 and above,there has been some fixes which made it possible for the code to download the image. Created a simple console application with the code in my question and it works with .Net 4.0 and above, but not with 3.5 which is the framework I need to use since Axapta 2009 can't handle .Net 4.0

    – Phu Minh Pham
    Dec 3 '18 at 15:37






  • 1





    Both WebClient and HttpWebRequest internally use a Uri. When using NET 3.5, the dot character already gets removed when instantiating a Uri, whereas NET 4.5 leaves it as-is.

    – pfx
    Dec 3 '18 at 18:43



















  • @Nkosi, try with Console App, NET 3.5 Apparently something is changed (fixed?) in the later NET Framework implementations

    – Ivan Stoev
    Dec 3 '18 at 10:34











  • @Nkosi Yes, it is. But something in NET 4.5 made this code works :)

    – Ivan Stoev
    Dec 3 '18 at 11:00











  • I don't think the code or the version is the problem, but the url itself. It seems that this part is the issue kr./, while this works fine https://valgfrigave.dk/image/cache/catalog/50%20kr/notesbog03_1000x1000px-228x228.jpg. Apparentlty dotnet cannot handle that dot in the url followed by a /.

    – VDWWD
    Dec 3 '18 at 11:32













  • @Ivan Stoev From .Net 4.0 and above,there has been some fixes which made it possible for the code to download the image. Created a simple console application with the code in my question and it works with .Net 4.0 and above, but not with 3.5 which is the framework I need to use since Axapta 2009 can't handle .Net 4.0

    – Phu Minh Pham
    Dec 3 '18 at 15:37






  • 1





    Both WebClient and HttpWebRequest internally use a Uri. When using NET 3.5, the dot character already gets removed when instantiating a Uri, whereas NET 4.5 leaves it as-is.

    – pfx
    Dec 3 '18 at 18:43

















@Nkosi, try with Console App, NET 3.5 Apparently something is changed (fixed?) in the later NET Framework implementations

– Ivan Stoev
Dec 3 '18 at 10:34





@Nkosi, try with Console App, NET 3.5 Apparently something is changed (fixed?) in the later NET Framework implementations

– Ivan Stoev
Dec 3 '18 at 10:34













@Nkosi Yes, it is. But something in NET 4.5 made this code works :)

– Ivan Stoev
Dec 3 '18 at 11:00





@Nkosi Yes, it is. But something in NET 4.5 made this code works :)

– Ivan Stoev
Dec 3 '18 at 11:00













I don't think the code or the version is the problem, but the url itself. It seems that this part is the issue kr./, while this works fine https://valgfrigave.dk/image/cache/catalog/50%20kr/notesbog03_1000x1000px-228x228.jpg. Apparentlty dotnet cannot handle that dot in the url followed by a /.

– VDWWD
Dec 3 '18 at 11:32







I don't think the code or the version is the problem, but the url itself. It seems that this part is the issue kr./, while this works fine https://valgfrigave.dk/image/cache/catalog/50%20kr/notesbog03_1000x1000px-228x228.jpg. Apparentlty dotnet cannot handle that dot in the url followed by a /.

– VDWWD
Dec 3 '18 at 11:32















@Ivan Stoev From .Net 4.0 and above,there has been some fixes which made it possible for the code to download the image. Created a simple console application with the code in my question and it works with .Net 4.0 and above, but not with 3.5 which is the framework I need to use since Axapta 2009 can't handle .Net 4.0

– Phu Minh Pham
Dec 3 '18 at 15:37





@Ivan Stoev From .Net 4.0 and above,there has been some fixes which made it possible for the code to download the image. Created a simple console application with the code in my question and it works with .Net 4.0 and above, but not with 3.5 which is the framework I need to use since Axapta 2009 can't handle .Net 4.0

– Phu Minh Pham
Dec 3 '18 at 15:37




1




1





Both WebClient and HttpWebRequest internally use a Uri. When using NET 3.5, the dot character already gets removed when instantiating a Uri, whereas NET 4.5 leaves it as-is.

– pfx
Dec 3 '18 at 18:43





Both WebClient and HttpWebRequest internally use a Uri. When using NET 3.5, the dot character already gets removed when instantiating a Uri, whereas NET 4.5 leaves it as-is.

– pfx
Dec 3 '18 at 18:43












1 Answer
1






active

oldest

votes


















2





+100









Problem



As already suspected in comments, the problem is that part of the URL, namely a dot, disappears. This seems to be a bug in .NET 3.5.



Here a screenshot of a https proxy: without the dot there is a 404 since this part of the URL is missing:



proxy



Solution for .NET 3.5



Since you need to stay on .NET 3.5 you can use this cool workaround from a SO answer: https://stackoverflow.com/a/31559579



In your code add the MyUri method from the link above and change the URI creation like so:



Uri innUri = MyUri(url);


Then the download works!



Result



result






share|improve this answer


























  • Added the suggested method to my code and replaced the URI creation and now we're able to download the image from the link. We give you a very big thank you! :D

    – Phu Minh Pham
    Dec 4 '18 at 9:29











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390151%2fwho-can-download-this-image-using-net-3-5%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2





+100









Problem



As already suspected in comments, the problem is that part of the URL, namely a dot, disappears. This seems to be a bug in .NET 3.5.



Here a screenshot of a https proxy: without the dot there is a 404 since this part of the URL is missing:



proxy



Solution for .NET 3.5



Since you need to stay on .NET 3.5 you can use this cool workaround from a SO answer: https://stackoverflow.com/a/31559579



In your code add the MyUri method from the link above and change the URI creation like so:



Uri innUri = MyUri(url);


Then the download works!



Result



result






share|improve this answer


























  • Added the suggested method to my code and replaced the URI creation and now we're able to download the image from the link. We give you a very big thank you! :D

    – Phu Minh Pham
    Dec 4 '18 at 9:29
















2





+100









Problem



As already suspected in comments, the problem is that part of the URL, namely a dot, disappears. This seems to be a bug in .NET 3.5.



Here a screenshot of a https proxy: without the dot there is a 404 since this part of the URL is missing:



proxy



Solution for .NET 3.5



Since you need to stay on .NET 3.5 you can use this cool workaround from a SO answer: https://stackoverflow.com/a/31559579



In your code add the MyUri method from the link above and change the URI creation like so:



Uri innUri = MyUri(url);


Then the download works!



Result



result






share|improve this answer


























  • Added the suggested method to my code and replaced the URI creation and now we're able to download the image from the link. We give you a very big thank you! :D

    – Phu Minh Pham
    Dec 4 '18 at 9:29














2





+100







2





+100



2




+100





Problem



As already suspected in comments, the problem is that part of the URL, namely a dot, disappears. This seems to be a bug in .NET 3.5.



Here a screenshot of a https proxy: without the dot there is a 404 since this part of the URL is missing:



proxy



Solution for .NET 3.5



Since you need to stay on .NET 3.5 you can use this cool workaround from a SO answer: https://stackoverflow.com/a/31559579



In your code add the MyUri method from the link above and change the URI creation like so:



Uri innUri = MyUri(url);


Then the download works!



Result



result






share|improve this answer















Problem



As already suspected in comments, the problem is that part of the URL, namely a dot, disappears. This seems to be a bug in .NET 3.5.



Here a screenshot of a https proxy: without the dot there is a 404 since this part of the URL is missing:



proxy



Solution for .NET 3.5



Since you need to stay on .NET 3.5 you can use this cool workaround from a SO answer: https://stackoverflow.com/a/31559579



In your code add the MyUri method from the link above and change the URI creation like so:



Uri innUri = MyUri(url);


Then the download works!



Result



result







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 3 '18 at 22:48

























answered Dec 3 '18 at 22:32









Stephan SchlechtStephan Schlecht

4,9951911




4,9951911













  • Added the suggested method to my code and replaced the URI creation and now we're able to download the image from the link. We give you a very big thank you! :D

    – Phu Minh Pham
    Dec 4 '18 at 9:29



















  • Added the suggested method to my code and replaced the URI creation and now we're able to download the image from the link. We give you a very big thank you! :D

    – Phu Minh Pham
    Dec 4 '18 at 9:29

















Added the suggested method to my code and replaced the URI creation and now we're able to download the image from the link. We give you a very big thank you! :D

– Phu Minh Pham
Dec 4 '18 at 9:29





Added the suggested method to my code and replaced the URI creation and now we're able to download the image from the link. We give you a very big thank you! :D

– Phu Minh Pham
Dec 4 '18 at 9:29




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390151%2fwho-can-download-this-image-using-net-3-5%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?