Tag: post

C#WebClient登录accounts.google.com

我很难尝试使用webclient对accounts.google.com进行身份validation 我正在使用C#WebClient对象来实现以下function。 我将表单字段提交到https://accounts.google.com/ServiceLoginAuth?service=oz 这是POST字段: service=oz dsh=-8355435623354577691 GALX=33xq1Ma_CKI timeStmp= secTok= Email=test@test.xom Passwd=password signIn=Sign in PersistentCookie=yes rmShown=1 现在,在我提交数据之前加载登录页面时,它有以下标题: Content-Type text/html; charset=UTF-8 Strict-Transport-Security max-age=2592000; includeSubDomains Set-Cookie GAPS=1:QClFh_dKle5DhcdGwmU3m6FiPqPoqw:SqdLB2u4P2oGjt_x;Path=/;Expires=Sat, 21-Dec-2013 07:31:40 GMT;Secure;HttpOnly Cache-Control no-cache, no-store Pragma no-cache Expires Mon, 01-Jan-1990 00:00:00 GMT X-Frame-Options Deny X-Auto-Login realm=com.google&args=service%3Doz%26continue%3Dhttps%253A%252F%252Faccounts.google.com%252FManageAccount Content-Encoding gzip Transfer-Encoding chunked Date Thu, 22 Dec 2011 07:31:40 GMT X-Content-Type-Options nosniff X-XSS-Protection […]

WebApi POST没有吗?

我有这个控制器动作: [HttpPost] [ActionName(“aaa”)] public HttpResponseMessage aaa(Z z) //notice – no [FromBody] { return Request.CreateResponse(HttpStatusCode.OK, 1); } Z是: public class Z { public string a { get; set; } } 但是当我通过提琴手发帖时: POST http://localhost:11485/api/profiles/aaa HTTP/1.1 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Host: localhost:11485 Content-Length: 3 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8,he;q=0.6 Cache-Control: no-cache Connection: keep-alive a=1 我实际上可以看到它正在工作: 题: 如果是这样,没有[FromBody]属性它如何工作? 我还需要/不写这个属性吗? 此外,不写这个属性的情况是什么 […]

Unity GET / POST Wrapper

这是C#问题中的Unity3d。 目标是创建一个对象,以便我可以传入URL并通过GET接收数据,我将创建一个对象,它将成为WWW逻辑的包装器。 我也想要一个’POST’对象,在那里我可以提供一个url和一个键值对的’Dictionary’作为post争论。 Sooo ……我们最终会喜欢这样的东西: get_data = GET.request(“http://www.someurl.com/somefile.php?somevariable=somevalue”); 和 post_data = POST.request(“http://www.someurl.com/somefile.php”, post) // Where post is a Dictionary of key-value pairs of my post arguments. 为了尝试实现这一点,我使用了WWW对象。 现在,为了给WWW对象下载时间,我们需要在MonoBehaviour对象中发生这种情况并yield结果。 所以我得到了这个,它有效: public class main : MonoBehavior { IEnumerator Start() { WWW www = new WWW(“http://www.someurl.com/blah.php?action=awesome_stuff”); yield return www; Debug.Log(www.text); } } 我真正想要的是: public class main : MonoBehavior […]

.NET HTTP POST方法 – Cookie问题

我正在尝试使用C#登录hotfile.com。 第一个大问题是克服417错误,这条线解决了它: System.Net.ServicePointManager.Expect100Continue = false; 现在,当我尝试使用POST登录时,我收到此错误: 您似乎不接受cookie。 需要Cookie才能登录。帮助 我已经尝试了好几次,然后用Google搜索,我仍然无法登录Hotfile.com ..我的代码是这样的: string response; byte[] buffer = Encoding.ASCII.GetBytes(“user=XX&pass=XX”); CookieContainer cookies = new CookieContainer(); HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(“http://hotfile.com/login.php”); WebReq.Credentials = new NetworkCredential(“XX”, “XX”); WebReq.PreAuthenticate = true; WebReq.Pipelined = true; WebReq.CookieContainer = cookies; WebReq.KeepAlive = true; WebReq.Method = “POST”; WebReq.ContentType = “application/x-www-form-urlencoded”; WebReq.ContentLength = buffer.Length; WebReq.UserAgent = “Mozilla/4.0 (compatible; […]

如何编写HTTP请求

您好我尝试在C#(Post)中编写HTTP请求,但我需要帮助解决错误 Expl:我想将DLC文件的内容发送到服务器并重新获取解密的内容。 C#代码 public static void decryptContainer(string dlc_content) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(“http://dcrypt.it/decrypt/paste”); request.Method = “POST”; request.ContentType = “application/x-www-form-urlencoded”; request.Accept = “Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8”; using (StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII)) { writer.Write(“content=” + dlc_content); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream())) { Console.WriteLine(reader.ReadToEnd()); } } 在这里我收到了html请求 DLC content Submit » 错误信息: { […]

Google Translate V2无法处理来自C#的大型文本翻译

我使用带有GET方法的Google Translation V2 api实现了C#代码。 它成功翻译了小文本,但是当增加文本长度并且需要1,800个字符(包括URI参数)时,我得到的“URI太大”错误。 好吧,我烧掉了所有的路径,并在互联网上发布的多个页面上调查了这个问题。 所有这些都明确表示应该重写GET方法来模拟POST方法(这意味着提供对5,000个字符URI的支持)但是没有办法找到它的代码示例。 有没有人有任何例子或可以提供一些信息? [ 编辑 ]这是我正在使用的代码: String apiUrl = “https://www.googleapis.com/language/translate/v2?key={0}&source={1}&target={2}&q={3}”; String url = String.Format(apiUrl, Constants.apiKey, sourceLanguage, targetLanguage, text); Stream outputStream = null; byte[] bytes = Encoding.ASCII.GetBytes(url); // create the http web request HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.KeepAlive = true; webRequest.Method = “POST”; // Overrride the GET method as documented on […]

将CURL转换为C#

我花了很多年的时间尝试各种不同的方法将这个curl转换为c#。 请有人帮忙。 我正在尝试做一个httppost并继续得到错误500.这是我要转换的内容: curl –user username:password -X POST -d “browser=Win7x64-C1|Chrome32|1024×768&url=http://www.google.com” http://crossbrowsertesting.com/api/v3/livetests/ 这是我到目前为止: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseurl); request.Method = “POST”; request.Accept = “application/json”; request.Credentials = new NetworkCredential(username, password); var response = request.GetResponse(); string text; using (var sr = new StreamReader(response.GetResponseStream())) { text = sr.ReadToEnd(); values.Add(text); } 尝试过这种方法,但它不起作用: List data = new List(); data.Add(“browser=Win7x64-C1|Chrome20|1024×768”); data.Add(“url=URL”); data.Add(“format=json”); data.Add(“callback=doit”); […]

将JSON数组发布到mvc控制器

我正在尝试将JSON数组发布到MVC控制器。 但无论我尝试什么,一切都是0或null。 我有这个包含文本框的表。 我需要从所有这些文本框中将ID和值作为对象。 这是我的Javascript: $(document).ready(function () { $(‘#submitTest’).click(function (e) { var $form = $(‘form’); var trans = new Array(); var parameters = { TransIDs: $(“#TransID”).val(), ItemIDs: $(“#ItemID”).val(), TypeIDs: $(“#TypeID”).val(), }; trans.push(parameters); if ($form.valid()) { $.ajax( { url: $form.attr(‘action’), type: $form.attr(‘method’), data: JSON.stringify(parameters), dataType: “json”, contentType: “application/json; charset=utf-8”, success: function (result) { $(‘#result’).text(result.redirectTo) if (result.Success […]