webrequest

How to use WebRequest to POST some data and read response?

对着背影说爱祢 提交于 2019-12-20 09:23:04
问题 Need to have the server make a POST to an API, how do I add POST values to a WebRequest object and how do I send it and get the response (it will be a string) out? I need to POST TWO values, and sometimes more, I see in these examples where it says string postData = "a string to post"; but how do I let the thing I am POSTing to know that there is multiple form values? 回答1: From MSDN // Create a request using a URL that can receive a post. WebRequest request = WebRequest.Create ("http:/

How to send POST request with parameters asynchronously in windows phone 8

隐身守侯 提交于 2019-12-20 04:24:38
问题 I would like to send POST request in windows phone 8 environment my code is running successfully but i am getting NotFound exception. Its mean is i want to POST some data but i am sending null. So please let me know how to send POST Request asynchronously with Data in windows phone 8 environmet. I tried following links but not helpful. link link2 I approached like this private async Task<LastRead> SyncLastReadPOST(LastRead lastreads, bool actionStatus) { string jsondata = ""; actionStatus =

Getting a Uri with escaped slashes on mono

六月ゝ 毕业季﹏ 提交于 2019-12-19 10:22:07
问题 Update: A fix has now made it's way into mono. This is good news! Updated: Added logic to fix fragment handling. I am trying to send a request with an encoded slash on Mono using the Uri class. This is basically the Mono equivalent of this question: GETting a URL with an url-encoded slash The issue is that Mono similar to .NET will unescape any slashes it finds in the Uri when it is constructed. This logic was originally put in in place in order to remove vulnerabilities that could occur if

instantiating an object from a web service vs instantiating an object from a regular class

旧时模样 提交于 2019-12-19 03:02:22
问题 I have a very basic web service: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; namespace WebService1 { /// <summary> /// Summary description for Service1 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. //

HttpWebRequests Failing on Subsequent Calls

£可爱£侵袭症+ 提交于 2019-12-18 16:56:18
问题 I know this is a vague question, especially since I am not providing any code, but I am developing a .Net 2.0 application, and we have a WebRequest which posts data to an internally built API. The strange thing happens on our 3rd (and always the 3rd) subsequent request which fails at the GetRequestStream() method of the request. The first and second time its called, all is fine. On the 3rd time, it hangs for a bit and eventually times out. The API is being called by other applications in

c# HttpWebRequest POST'ing failing

限于喜欢 提交于 2019-12-18 15:55:34
问题 So i'm trying to POST something to a webserver. System.Net.HttpWebRequest EventReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("url"); System.String Content = "id=" + Id; EventReq.ContentLength = System.Text.Encoding.UTF8.GetByteCount(Content); EventReq.Method = "POST"; EventReq.ContentType = "application/x-www-form-urlencoded"; System.IO.StreamWriter sw = new System.IO.StreamWriter(EventReq.GetRequestStream(), System.Text.Encoding.UTF8); sw.Write(Content); sw.Flush(); sw

How to make ordinary WebRequest async and awaitable?

孤者浪人 提交于 2019-12-18 11:59:36
问题 I need to make the following code async and awaitable. I need to get a lot of data from the web server, and then this data will be used to populate the xaml page in my application. So, I need the DefLogin() method to be awaitable. Is it possible? public void DefLogin() { postData = "My Data To Post"; var url = new Uri("Url To Post to", UriKind.Absolute); webRequest = WebRequest.Create(url); webRequest.Method = "POST"; webRequest.ContentType = "text/xml"; webRequest.BeginGetRequestStream(new

Reading data from an open HTTP stream

三世轮回 提交于 2019-12-18 11:52:20
问题 I am trying to use the .NET WebRequest/WebResponse classes to access the Twitter streaming API here "http://stream.twitter.com/spritzer.json" . I need to be able to open the connection and read data incrementally from the open connection. Currently, when I call WebRequest.GetResponse method, it blocks until the entire response is downloaded. I know there is a BeginGetResponse method, but this will just do the same thing on a background thread. I need to get access to the response stream while

Reasons for a 409/Conflict HTTP error when uploading a file to sharepoint using a .NET WebRequest?

被刻印的时光 ゝ 提交于 2019-12-18 11:46:42
问题 I've got a method that uses a WebRequest to upload a file to a sharepoint 2010 list/folder, using a PUT request, with the Overwrite Header set to T (overwrite). When several files are uploaded (method is called several times), some requests fail with a 409 Conflict HTTP error. I've googled, and it seems the most common reason is trying to affect/update a file that does not exist (like setting the request URL to a path without a file name). However, that is not the case. In case the conflict

HttpWebRequest: Add Cookie to CookieContainer -> ArgumentException (Parametername: cookie.Domain)

北战南征 提交于 2019-12-17 22:37:56
问题 I'm trying to login to a website via my application. What I did: First I figured out how the browser does the authorization process with Fiddler. I examined how the POST request is built and I tried to reconstruct it. The browser sends 4 cookies (Google Analytics) and I tried to set them: CookieContainer gaCookies = new CookieContainer(); gaCookies.Add(new Cookie("__utma", "#########.###########.##########.##########.##########.#")); gaCookies.Add(new Cookie("__utmb", "#########.#.##.########