问题描述
publicstaticstringPostData(Uriuri,NameValueCollectionvalues,[Optional,DefaultParameterValue(true)]boolstatus){try{HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(uri);request.Method="POST";request.ContentType="application/x-www-form-urlencoded";request.Accept="*/*";request.Headers.Add("Accept-Encoding:gzip,deflate");request.Headers.Add("Accept-Language:zh-cn");request.ServicePoint.Expect100Continue=false;request.KeepAlive=false;request.Timeout=300000;request.ReadWriteTimeout=300000;request.UserAgent="Mozilla/5.0(iPad;CPUOS6_0likeMacOSX)AppleWebKit/536.26(KHTML,likeGecko)Version/6.0Mobile/10A403Safari/8536.25";if(status){CookieContainercontainer=newCookieContainer();container.Add(uri,newCookie("cookie",""));//container.Add(uri,newCookie("Version",this.Version));request.CookieContainer=container;}strings=string.Empty;if(values!=null){foreach(stringstr2invalues.Keys){s=s+string.Format("{0}={1}&",str2,values[str2]);}s=s.Remove(s.Length-1);}byte[]bytes=Encoding.UTF8.GetBytes(s);StreamrequestStream=request.GetRequestStream();requestStream.Write(bytes,0,bytes.Length);requestStream.Close();StreamReaderreader=newStreamReader(request.GetResponse().GetResponseStream(),Encoding.UTF8);returnreader.ReadToEnd();}catch(Exceptionexception){returnnull;//this.AddLog("网络错误",500,exception.Message);}}}这是我的代码,请问一下大神们。在win7和xp系统中这个东西还有区别么?是使用的4的,理论上跟XP是通用的。但是在XP上出400的异常了。
解决方案
解决方案二:
解决方案三:
生成->配置管理器,设置程序的环境,改成x86吧,对64位不影响程序的。