Method HttpContent.ReadAsStringAsync() returns invalid html code. How it can be?Can HTML checkboxes be set to readonly?How can I know which radio button is selected via jQuery?How to use HTML Agility packHow can I select an element by name with jQuery?How to mark a method as obsolete or deprecated?What characters can be used for up/down triangle (arrow without stem) for display in HTML?How to create an HTML button that acts like a link?How can I set the default value for an HTML <select> element?How to create a checkbox with a clickable label?How do I reformat HTML code using Sublime Text 2?

Why radial coordinate of a particle must decrease continuously once it is inside the Schwarzschild radius?

Sci-fi change: Too much or Not enough

Can an Oathbreaker Paladin reform and choose a different Paladin subclass?

Can a US President, after impeachment and removal, be re-elected or re-appointed?

(3 of 11: Akari) What is Pyramid Cult's Favorite Car?

How did the Axis intend to hold the Caucasus?

Is there a way to know the composition of a Team GO Rocket before going into the fight?

What container to use to store developer concentrate?

Struggling with cyclical dependancies in unit tests

Desktop app status bar: Notification vs error message

Why did Windows 95 crash the whole system but newer Windows only crashed programs?

Compound Word Neologism

Are the named pipe created by `mknod` and the FIFO created by `mkfifo` equivalent?

2 weeks and a tight budget to prepare for Z-day. How long can I hunker down?

Is it error of law to judge on less relevant case law when there is much more relevant one?

How do you pronounce "Hain"?

If Trump gets impeached, how long would Pence be president?

Are there any unpublished Iain M. Banks short stories?

reconstruction filter - How does it actually work?

Is there an antonym for "spicy" or "hot" regarding food (NOT "seasoned" but "spicy")?

When I cite content from a book, should I say "section 2.3.2.1 of book... " or "section 2.3.2.1 of `the` book ..."?

Why not notify faculty candidates of the position being filled?

Why isn't there any 9.5 digit multimeter or higher?

How can I kill my goat?



Method HttpContent.ReadAsStringAsync() returns invalid html code. How it can be?


Can HTML checkboxes be set to readonly?How can I know which radio button is selected via jQuery?How to use HTML Agility packHow can I select an element by name with jQuery?How to mark a method as obsolete or deprecated?What characters can be used for up/down triangle (arrow without stem) for display in HTML?How to create an HTML button that acts like a link?How can I set the default value for an HTML <select> element?How to create a checkbox with a clickable label?How do I reformat HTML code using Sublime Text 2?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Here is some code,to request html-code from url.



var currentUrl = "https://www.google.com";
HttpClient client = new HttpClient();
System.Diagnostics.Process.Start(currentUrl); //here i open a browser with same URL,
var response = await client.GetAsync(currentUrl);
string sourse = null;


if (response != null && response.StatusCode == HttpStatusCode.OK)

sourse =await response.Content.ReadAsStringAsync(); // here i get the html-code



SO, the questions is: why html code that i get from program,and html code from real page in browser i have opened few secods before are different? It doesn't make sence.



Also, here is some proofs. First image - number of character in browser-html code
enter image description here



... and in program-html code enter image description here



I gave the simplest evidence, to make the question more easier.
But if I dig deeper, the html code comes from nowhere. When I parse a specific page, and it should be 39 products, the program returns the html code, which only 6 products (which, incidentally, are not included in the 39 those that are actually on the page in the browser). So I asked the question so simply.
Really,i make a new project a minute ago with this code, and it work incorrect as I wrote above. to get the code that the program returns, I can look it up in the sourse variable or leave it in a file, and then compare. Like:



 FileStream fs = new FileStream("report.txt", FileMode.OpenOrCreate);
StreamWriter SW = new StreamWriter(fs);
SW.WriteLine(sourse);









share|improve this question


























  • What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?

    – mason
    Mar 26 at 19:27











  • HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.

    – DSakura
    Mar 26 at 22:29











  • Hmmm, ok. But how can i load the page like in the browser,and get correct html code?

    – Mister Crabs
    Mar 26 at 23:23











  • @MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?

    – DSakura
    Mar 27 at 19:59


















0















Here is some code,to request html-code from url.



var currentUrl = "https://www.google.com";
HttpClient client = new HttpClient();
System.Diagnostics.Process.Start(currentUrl); //here i open a browser with same URL,
var response = await client.GetAsync(currentUrl);
string sourse = null;


if (response != null && response.StatusCode == HttpStatusCode.OK)

sourse =await response.Content.ReadAsStringAsync(); // here i get the html-code



SO, the questions is: why html code that i get from program,and html code from real page in browser i have opened few secods before are different? It doesn't make sence.



Also, here is some proofs. First image - number of character in browser-html code
enter image description here



... and in program-html code enter image description here



I gave the simplest evidence, to make the question more easier.
But if I dig deeper, the html code comes from nowhere. When I parse a specific page, and it should be 39 products, the program returns the html code, which only 6 products (which, incidentally, are not included in the 39 those that are actually on the page in the browser). So I asked the question so simply.
Really,i make a new project a minute ago with this code, and it work incorrect as I wrote above. to get the code that the program returns, I can look it up in the sourse variable or leave it in a file, and then compare. Like:



 FileStream fs = new FileStream("report.txt", FileMode.OpenOrCreate);
StreamWriter SW = new StreamWriter(fs);
SW.WriteLine(sourse);









share|improve this question


























  • What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?

    – mason
    Mar 26 at 19:27











  • HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.

    – DSakura
    Mar 26 at 22:29











  • Hmmm, ok. But how can i load the page like in the browser,and get correct html code?

    – Mister Crabs
    Mar 26 at 23:23











  • @MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?

    – DSakura
    Mar 27 at 19:59














0












0








0








Here is some code,to request html-code from url.



var currentUrl = "https://www.google.com";
HttpClient client = new HttpClient();
System.Diagnostics.Process.Start(currentUrl); //here i open a browser with same URL,
var response = await client.GetAsync(currentUrl);
string sourse = null;


if (response != null && response.StatusCode == HttpStatusCode.OK)

sourse =await response.Content.ReadAsStringAsync(); // here i get the html-code



SO, the questions is: why html code that i get from program,and html code from real page in browser i have opened few secods before are different? It doesn't make sence.



Also, here is some proofs. First image - number of character in browser-html code
enter image description here



... and in program-html code enter image description here



I gave the simplest evidence, to make the question more easier.
But if I dig deeper, the html code comes from nowhere. When I parse a specific page, and it should be 39 products, the program returns the html code, which only 6 products (which, incidentally, are not included in the 39 those that are actually on the page in the browser). So I asked the question so simply.
Really,i make a new project a minute ago with this code, and it work incorrect as I wrote above. to get the code that the program returns, I can look it up in the sourse variable or leave it in a file, and then compare. Like:



 FileStream fs = new FileStream("report.txt", FileMode.OpenOrCreate);
StreamWriter SW = new StreamWriter(fs);
SW.WriteLine(sourse);









share|improve this question
















Here is some code,to request html-code from url.



var currentUrl = "https://www.google.com";
HttpClient client = new HttpClient();
System.Diagnostics.Process.Start(currentUrl); //here i open a browser with same URL,
var response = await client.GetAsync(currentUrl);
string sourse = null;


if (response != null && response.StatusCode == HttpStatusCode.OK)

sourse =await response.Content.ReadAsStringAsync(); // here i get the html-code



SO, the questions is: why html code that i get from program,and html code from real page in browser i have opened few secods before are different? It doesn't make sence.



Also, here is some proofs. First image - number of character in browser-html code
enter image description here



... and in program-html code enter image description here



I gave the simplest evidence, to make the question more easier.
But if I dig deeper, the html code comes from nowhere. When I parse a specific page, and it should be 39 products, the program returns the html code, which only 6 products (which, incidentally, are not included in the 39 those that are actually on the page in the browser). So I asked the question so simply.
Really,i make a new project a minute ago with this code, and it work incorrect as I wrote above. to get the code that the program returns, I can look it up in the sourse variable or leave it in a file, and then compare. Like:



 FileStream fs = new FileStream("report.txt", FileMode.OpenOrCreate);
StreamWriter SW = new StreamWriter(fs);
SW.WriteLine(sourse);






c# html dotnet-httpclient httpcontent






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 19:41









Amy

22.9k19 gold badges76 silver badges134 bronze badges




22.9k19 gold badges76 silver badges134 bronze badges










asked Mar 26 at 19:19









Mister CrabsMister Crabs

113 bronze badges




113 bronze badges















  • What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?

    – mason
    Mar 26 at 19:27











  • HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.

    – DSakura
    Mar 26 at 22:29











  • Hmmm, ok. But how can i load the page like in the browser,and get correct html code?

    – Mister Crabs
    Mar 26 at 23:23











  • @MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?

    – DSakura
    Mar 27 at 19:59


















  • What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?

    – mason
    Mar 26 at 19:27











  • HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.

    – DSakura
    Mar 26 at 22:29











  • Hmmm, ok. But how can i load the page like in the browser,and get correct html code?

    – Mister Crabs
    Mar 26 at 23:23











  • @MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?

    – DSakura
    Mar 27 at 19:59

















What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?

– mason
Mar 26 at 19:27





What makes you think it's invalid? How can you tell? And have you considered that your browser may be providing a lot more HTTP headers when it makes that GET request to google than your HttpClient is?

– mason
Mar 26 at 19:27













HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.

– DSakura
Mar 26 at 22:29





HttpClient is not browser. Browser will download the page, render it and run scripts in it, HttpClient will not do it.

– DSakura
Mar 26 at 22:29













Hmmm, ok. But how can i load the page like in the browser,and get correct html code?

– Mister Crabs
Mar 26 at 23:23





Hmmm, ok. But how can i load the page like in the browser,and get correct html code?

– Mister Crabs
Mar 26 at 23:23













@MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?

– DSakura
Mar 27 at 19:59






@MisterCrabs You are looking at browser controls, like cefsharp.github.io, or .Net Framework's WebBrowser. No matter what you choose, you should check your goal. Why are you getting HTML code?

– DSakura
Mar 27 at 19:59













0






active

oldest

votes










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%2f55364768%2fmethod-httpcontent-readasstringasync-returns-invalid-html-code-how-it-can-be%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















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%2f55364768%2fmethod-httpcontent-readasstringasync-returns-invalid-html-code-how-it-can-be%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

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript