httpwebrequest

Changing absolute URI to relative in HTTP POST header

江枫思渺然 提交于 2019-12-25 03:55:18
问题 I have the following POST request: POST http://blah/Request HTTP/1.1 Host: blah Content-Length: 322 Proxy-Connection: Keep-Alive <?xml version="1.0"?> <Envelope> <Header> <UserID>uid</UserID> <Password>pass</Password> <SessionID /> <RequestType>GetDetails</RequestType> <POSCompany>01</POSCompany> <PackageType>DATA</PackageType> <ActionType>READ</ActionType> <SnoopUserID /> </Header> <Body> <MagicNumber>124</MagicNumber> </Body> </Envelope> This is failing with the error - (405) Method not

jquery ajax call fails with 401 unauthorized

情到浓时终转凉″ 提交于 2019-12-25 03:53:53
问题 I have a jquery ajax POST to a code-behind webmethod. In that webmethod i do a HttpWebRequest to a third party web api service that returns json. Even though the httpwebrequest works fine, a popup appears in the browser asking me to enter credentials (authentication required). On my machine this works well, however when deployed it doesn't except if there is no data returned from the httpwebrequest call. The jquery call: function serverCall(httpMethod, pageName, methodName, inputData,

Getting remote file size without content-length

落花浮王杯 提交于 2019-12-25 03:45:18
问题 so I've figured on how to get remote files their file size from over the internet with the following code: WebRequest req = WebRequest.Create(url); req.Method = "HEAD"; using (WebResponse resp = req.GetResponse()) { int ContentLength; if (int.TryParse(resp.Headers.Get("Content-Length"), out ContentLength)) { // Stuff ~ } } How do I get a remote file its size without the Content-Length option? I'm really out of ideas and I've searched the internet for several hours, being unable to find it. If

On WP8.1 ONLY: cannot read more than 65536 bytes off an HTTP Stream

北城以北 提交于 2019-12-25 03:03:53
问题 Hope someone could please provide any help on an issue I'm struggling for quite a lot of time. Goal : I need to read an http stream from a specified URI, that I startup & endlessly read with the following code (which I stripped down to minimum so to really focus on the bare communication problem): public void StartupStream(Uri uri) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); // Start the asynchronous request request.BeginGetResponse(OnGetResponse, request); }

Why is the HttpWebRequest body val null after “crossing the Rubicon”?

余生颓废 提交于 2019-12-25 02:49:14
问题 I am trying to send the contents of an XML file from a handheld device (Compact Framework/Windows CE) to a Web API method in my server app like so (Client code): public static string SendXMLFile(string xmlFilepath, string uri, int timeout) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.KeepAlive = false; request.ProtocolVersion = HttpVersion.Version10; request.Method = "POST"; StringBuilder sb = new StringBuilder(); using (StreamReader sr = new StreamReader

Silverlight WebRequest fails with “The URI prefix is not recognized”

让人想犯罪 __ 提交于 2019-12-25 02:44:47
问题 I have a silverlight library that is supposed to get make a web service request and receive an xml response: Uri uri = new Uri("http://some_server:51306/getStuff.xml?id=14"); WebRequest request = WebRequest.Create(uri); However, WebRequest.Create(uri) fails with the exception "The URI prefix is not recognized". Note that I am running the program using a unit test from a non-silverlight dll. I need to build a test suite for the app! Any ideeas? 回答1: Try setting the .Web project as the default

HttpWebRequest timeout in 3.5sp1

﹥>﹥吖頭↗ 提交于 2019-12-25 02:27:11
问题 We have a service that opens several HttpWebRequests. It ran fine under 3.0 until we upgraded the server to .net 3.5sp1. Now we get timeouts while waiting for the request. (we have verified that the endpoint is up and running). There are a few things that make this interesting. Increasing the number of max connections will let it run for a little longer before the timeouts occur. Also, once we see the requests waiting, if we open Fiddler they all succeed. These requests open via a Timer

Receive post data from a 3rd party within a webview

假装没事ソ 提交于 2019-12-25 01:48:39
问题 Stuck on an issue with http post data. So we've created a webview to work in. Then called a third party webservice this ask's to provide a postback url and some parameters, the webservice then processes the paramaters and redirects the user (our app) to the postback url we provided, with some data as a http post. We want to get the post data from this postback url but within the webview or within our app. Tried intercepting the url load with this code: final WebView webview = new WebView(this

Silverlight 4 HttpWebRequest user agent string is null

Deadly 提交于 2019-12-25 00:42:52
问题 The problem I have a page with a silverlight object. It attempts to retrieve XML from another (external cross domain) page. But I am struggling with a security exception. I have this code working brilliantly in WPF. When using a website hosting a silverlight application with the same code, the user agent string of the HttpRequest object is null (and seemingly cannot be set). In fact there is no header information at all - this causes a security exception when attempting to make my

Get content of response with StatusCode 401

十年热恋 提交于 2019-12-25 00:36:45
问题 I'm trying to establish a connection to a server that sends 401 Authentication Error for all my requests along with the normal html response. e.g. However, I also want to read the HTML response that is sent alongwith so that I can parse that. An example header exchange captured using LiveHTTPHeaders: Clearly, content-length is non-zero. Firefox shows it to be javascript. https://172.31.1.251:1003/fgtauth?73e285357b2dc5cc Request: GET /fgtauth?73e285357b2dc5cc HTTP/1.1 Host: 172.31.1.251:1003