Your server is returning HTTP 1201
which is not a standard status code.
WebClient
will fail with an exception when facing a non-successful status code (or an unrecognized one, in your case).
I encorauge you to use the new HttpClient class if you can:
public async Task<string> SendWebRequest(string requestUrl) { using (HttpClient client = new HttpClient()) using (HttpResponseMessage response = await client.GetAsync(requestUrl)) return await response.Content.ReadAsStringAsync(); }
If you have to do it synchronously:
public string SendWebRequest(string requestUrl) { using (HttpClient client = new HttpClient()) using (HttpResponseMessage response = client.GetAsync(requestUrl).GetAwaiter().GetResult()) return response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); }
Related Posts:
- What does vary:accept-encoding mean?
- Getting “Handshake failed…unexpected packet format” when using WebClient.UploadFile() with “https” when the server has a valid SSL certificate
- How do I generate a random int number?
- Why has the int32 type a maximum value of 2³¹ − 1? [duplicate]
- An existing connection was forcibly closed by the remote host
- Unexplained crashes related to ntdll.dll
- I am getting Failed to load resource: net::ERR_BLOCKED_BY_CLIENT with Google chrome
- What is parsing?
- Do I need Content-Type: application/octet-stream for file download?
- How to fix “HTTP Error 400. The size of the request headers is too long” error from azure cloud services?
- Could not load file or assembly or one of its dependencies
- Adding values to a C# array
- Algorithms in O(n^2) vs O(n) [duplicate]
- LINQ’s Distinct() on a particular property
- Priority queue in .Net
- What is the difference between int, Int16, Int32 and Int64?
- Adding values to a C# array
- How can I add ” character to a multi line string declaration in C#?
- Input string was not in a correct format
- The request was aborted: Could not create SSL/TLS secure channel
- Unable to connect to web server ‘IIS Express’
- Twilio TwilioRestClient does not contain a definition for SendSmsMessage
- How to convert byte array to string
- ASP.NET Core Dependency Injection error: Unable to resolve service for type while attempting to activate
- System.web.mvc missing
- What does HTTP/1.1 302 mean exactly?
- Nullable object must have a value?
- Sequence contains no elements?
- Best way to generate a random float in C#
- Check if list is empty in C#
- What is clr.dll on .Net framework and what does it do?
- How can I secure passwords stored inside web.config?
- Where can I find System.Web.Helpers, System.Web.WebPages, and System.Web.Razor?
- Visual Studio says “Method must have a return type”
- How to Use TextureBrush for painting an Image
- C# compiler error: “not all code paths return a value”
- How do I read and parse an XML file in C#?
- How to fix “namespace x already contains a definition for x” error? Happened after converting to VS2010
- How do I create a Shared Code project (.shproj)
- OnCollisionEnter2D not being executed?
- The calling thread cannot access this object because a different thread owns it
- Convert JSON String To C# Object
- How can I fix Visual Studio 2015 exception Microsoft.vshup.server.httphostx64.exe has stopped working when run project
- Could not establish trust relationship for SSL/TLS secure channel — SOAP
- How to convert an Stream into a byte[] in C#?
- IEnumerable vs List – What to Use? How do they work?
- How to convert code from C# to PHP
- Index was out of range. Must be non-negative and less than the size of the collection parameter name:index
- Is dependency injection useful in C++
- Parse Json string in C#
- System.BadImageFormatException: Could not load file or assembly
- HTML.ActionLink method
- Could not load file or assembly ‘Microsoft.Web.Infrastructure,
- Thread-safe List
property - Where to place native DLL to use Pocket PC emulator?
- Styles.Render in MVC4
- Exception from HRESULT: 0x800A03EC Error
- What is the purpose of the vshost.exe file?
- System.ComponentModel.Win32Exception: Access is denied Error
- Excel “External table is not in the expected format.”
- MSSQL Error ‘The underlying provider failed on Open’
- An object reference is required to access a non-static member
- Task vs Thread differences
- There is no ViewData item of type ‘IEnumerable
‘ that has the key country - C# – Rounding Down to Nearest Integer
- How to update the value stored in Dictionary in C#?
- How to write a comment in a Razor view?
- Finalize vs Dispose
- How to download a file from a URL in C#?
- Substring index and length must refer to a location within the string
- Difference between Method and Function?
- Calculate a MD5 hash from a string
- The model item passed into the dictionary is of type .. but this dictionary requires a model item of type
- How can I get the active screen dimensions?
- Catch multiple exceptions at once?
- How to delete a file after checking whether it exists
- c# Show Windows Form
- Equivalent of console.log in C#
- How to get the URL of the current page in C#
- C# Debug – cannot start debugging because the debug target is missing
- ‘namespace’ but is used like a ‘type’
- How can I delete a file that is in use by another process?
- How to properly make a http web GET request
- Strip double quotes from a string in .NET
- Simulating Key Press C#
- No overload for method ” takes 1 argument
- Best way to “push” into C# array
- Is it possible to install a C# compiler without Visual Studio?
- Playing a MP3 file in a WinForm application
- The server tag is not well formed error
- Func vs. Action vs. Predicate [duplicate]
- How to solve Operator ‘!=’ cannot be applied to operands of type ‘T’ and ‘T’
- Best way to randomize an array with .NET
- Encrypt and decrypt a string in C#?
- Key Value Pair List
- Using .Select and .Where in a single LINQ statement
- How to resize an Image C#
- Unrecognized escape sequence for path string containing backslashes
- C# Dictionary get item by index
- A field initializer cannot reference the nonstatic field, method, or property