使用get方法进行响应 [英] Using get method for response

查看:70
本文介绍了使用get方法进行响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 HttpWebRequest req =(HttpWebRequest)WebRequest.Create(SMSString); 
req.Method = GET;
ASCIIEncoding encoding = new ASCIIEncoding();
req.ContentType = application / x-www-form-urlencoded;
req.KeepAlive = true ;
System.Net.HttpWebResponse webresponse = null ;
webresponse =(HttpWebResponse)req.GetResponse();
StreamReader reader = new StreamReader(webresponse.GetResponseStream(),Encoding.Default);
result = reader.ReadToEnd();







上面有任何问题代码,因为我在某些情况下获得成功,在相同情况下获得异常。

解决方案

在少数情况下你会获得成功,那是因为代码没问题!



在某些情况下你会遇到异常,那是因为你在网络上工作,在继续测试之前你需要考虑很多事情应用程序,网络状态,协议和许多其他因素开始起作用,可能会导致异常。这个例外对你很有帮助,以获得帮助。大部分例外都是自我解释,因此您可以了解问题发生的原因,或者您可以尝试使用Google搜索获取帮助,或者您可以搜索CodeProject以获取有关该特定主题的任何先前答案;异常。

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(SMSString);
                req.Method = "GET";
                ASCIIEncoding encoding = new ASCIIEncoding();
                req.ContentType = "application/x-www-form-urlencoded";
                req.KeepAlive = true;
                System.Net.HttpWebResponse webresponse = null;
                webresponse = (HttpWebResponse)req.GetResponse();
                StreamReader reader = new StreamReader(webresponse.GetResponseStream(), Encoding.Default);
                result = reader.ReadToEnd();




is there any issue in above above code as i get success in some cases and exception in same cases.

解决方案

You get success in a few cases, that is because the code is OK!

You get exceptions in some cases, that is because you're working on the network, and there are a lot of things you need to consider before moving on to test the applications, network status, protocols and many other factors come into action and can cause an exception. That exception is a lot helpful to you, in order to get help. Most of the exception are self explaining, so you will get an idea of why the problem occured, or you can try to use the Google search to get help, or you can search CodeProject for any previous answers on that particular topic; exception.


这篇关于使用get方法进行响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆