简体   繁体   English

HttpWebRequest和HttpWebResponse

[英]HttpWebRequest and HttpWebResponse

I am trying to get the Response string by using C#'s WebRequest and WebResponse classes. 我试图通过使用C#的WebRequest和WebResponse类获取Response字符串。

It pulls the string but some part such as forms are missing from response.But when I open the same URL in browser(manually) and inspect elements using firebug it shows every thing. 它拉出字符串,但是响应中缺少诸如表单之类的部分。但是当我(手动)在浏览器中打开相同的URL并使用Firebug检查元素时,它可以显示所有内容。

What may be the problem that I am not getting complete response from WebResponse...??? 我没有从WebResponse收到完整响应的问题可能是什么...?

There are several reasons possible (Javascript, IFRAMEs etc.), for example: 有几种可能的原因(Javascript,IFRAME等),例如:

IF the site is using AJAX/JavaScript to build those forms dynamically on the client THEN what you see is correct... Background: since WebRequest does not execute Javascript the result "HttpWebRequest" versus Browser is different... 如果站点使用AJAX / JavaScript在客户端上动态构建这些表单,那么您看到的是正确的...背景:由于WebRequest不执行Javascript,因此结果“ HttpWebRequest”与浏览器不同...

Because WebRequest does not run Javascript code inserted into website. 因为WebRequest不会运行插入网站的Javascript代码。 You would have to evaluate javascript by yourself. 您将必须自己评估javascript。 Duplicate: C# httpwebrequest and javascript 重复: C#httpwebrequest和javascript

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM