Search code examples
c#httpwebrequestmeta

HttpWebRequest.GetResponseStream returns an empty string


I have been trying every way possible to download get the response stream from a page using HttpWebRequest, which works fine on everything else but no this page. As you see the data returned is an HTML but it have a some meta tag which I am not expert in, but what ever i try to get this block

{"error":4,"message":"Unsupported link format or unsupported hoster"}

It seems that I can't, I tried to specify the GET content-type as "text/json" but nothing helped.

Below is the HTML content returned when I open the page on the browser, but in code it returns empty string.

    <html>
    <meta style="visibility: hidden !important; display: block !important; width: 0px !important; height: 0px !important; border-style: none !important;"></meta>
    <head></head>
    <body>
      <pre style="word-wrap: break-word; white-space: pre-wrap;">{"error":4,"message":"Unsupported link format or unsupported hoster"}
      </pre>
    </body>
    </html>

Edit:

I have tried copy the same html above in a page on localhost and tried to fetch it's content and it actually worked, could there maybe some restriction in the IIS that could prevent fetching content ?


Solution

  • Do you have evidence that the problem is with the client? The more appropriate question is: Why is the server sending this strange content? The client just receives whatever the server sends.

    I suggest you debug the server to find out, or ask a new question containing your server-side code and asking specifically about it.