简体   繁体   English

C#.net System.Net.WebClient ..服务器端还是没有?

[英]C#.net System.Net.WebClient .. Server Side or not?

I have a C#.net webform that does a simple response.write in content type JSON format. 我有一个C#.net网络表单,它以内容类型JSON格式进行简单的response.write。 It works greats from every client I test it with - including a TinyWebDB API call from an Android phone.. but don't worry about that API for this question. 我测试过的每个客户端都可以很好地使用它-包括从Android手机中调用TinyWebDB API的方法。.但是不必担心该API会遇到这个问题。

I added some serverside code to that web form to read and scrape a web page as follows. 我向该Web表单添加了一些服务器端代码,以读取和抓取Web页面,如下所示。

System.Net.WebClient myWebClient = new System.Net.WebClient();
Stream myStream = myWebClient.OpenRead(what);
StreamReader sr = new StreamReader(myStream);
string s = sr.ReadToEnd();

I'm under the impression that code is all Server Side!? 我觉得代码全是服务器端!

I tested the page from IE, FF and Chrome.. all work great. 我测试了IE,FF和Chrome的页面。 However If I attempt to call the web form page from TinyWebDB the call works great and I get data back, but I get a 404 error on the server side read of the webpage?? 但是,如果我尝试从TinyWebDB调用Web表单页面,则该调用效果很好,并且我获取了数据,但是在服务器端读取的网页上却出现404错误?

It's almost as if System.Net.WebClient requires something from or is doing something on client itself. 这几乎就像System.Net.WebClient需要客户端本身或在客户端本身上执行某些操作一样。 i thought the reading of the page was all happening serverside and behind the scenes on my serer. 我认为该页面的阅读都是在服务器端发生的,而在我的后台发生。 Why would my serverside code care about what browser or API initiated the call to the webform? 我的服务器端代码为什么要关心哪种浏览器或API发起了对Webform的调用?

Should I be using another class? 我应该使用其他课程吗?

Many Thanks. 非常感谢。

That is serverside code. 那就是服务器端代码。

Where does the variable "what" get set? 变量“ what”在哪里设置? Is the form TinyWebDB client munging your form input values? TinyWebDB表单客户端在改变您的表单输入值吗?

Is it possible that the site you are requesting is rejecting your request because you're hitting it too fast and you've just been unlucky with it being that client every time? 您所请求的网站是否有可能因为您打的太快而拒绝了您的请求,而您不幸每次都成为该客户端吗?

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

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