httpwebrequest

“The format of the URI could not be determined” with WebRequest

前提是你 提交于 2019-12-23 07:12:15
问题 I'm trying to perform a POST to a site using a WebRequest in C#. The site I'm posting to is an SMS site, and the messagetext is part of the URL. To avoid spaces in the URL I'm calling HttpUtility.Encode() to URL encode it. But I keep getting an URIFormatException - "Invalid URI: The format of the URI could not be determined" - when I use code similar to this: string url = "http://www.stackoverflow.com?question=a sentence with spaces"; string encoded = HttpUtility.UrlEncode(url); WebRequest r

.Net CF 2.0 HttpWebRequest pre-authentication and sending credentials on first request

纵饮孤独 提交于 2019-12-23 04:17:06
问题 I'm attempting to communicate with bit.ly's REST API using their modified version of basic authentication. However in order for this to work HttpWebRequest needs to attach the credentials on the first request, however, HttpWebRequest will not send credentials on the first request and will wait for a 401 before sending any credentials even if PreAuthenticate is set to true (with PreAuthenticate it will send credentials for all subsequent requests). I have attempted the following to get

How do I need to read/know in order to log into a site and perform an action? [duplicate]

为君一笑 提交于 2019-12-23 04:01:55
问题 This question already has answers here : C# .NET Cookie Handling For After Login (2 answers) Closed 4 months ago . This is a mini project that has been tasked to me as part of a 'teach myself to code marathon'. I need to Log into a website that requires a user/pass (e.g facebook) and return the response. I have managed to achieve that using WebRequest and WebResponse classes. The next step is to send a message to my tutor programmatically This is where I am stumped. How do I access the 'send

WebRequest and System.Net.WebException on 404, slow?

荒凉一梦 提交于 2019-12-23 03:19:15
问题 I am using a WebRequest to check if a web page or media (image) exist. On GetResponse i get a System.Net.WebException exception. I ran through 100 links and it feels like its going slower then it should. Is there a way to not get this exception or handle this more gracefully? static public bool CheckExist(string url) { HttpWebRequest wreq = null; HttpWebResponse wresp = null; bool ret = false; try { wreq = (HttpWebRequest)WebRequest.Create(url); wreq.KeepAlive = true; wresp = (HttpWebResponse

Cookies in perl lwp

本小妞迷上赌 提交于 2019-12-23 03:14:07
问题 I once wrote a simple 'crawler' to download http pages for me in JAVA. Now I'm trying to rewrite to same thing to Perl, using LWP module. This is my Java code (which works fine): String referer = "http://example.com"; String url = "http://example.com/something/cgi-bin/something.cgi"; String params= "a=0&b=1"; HttpState initialState = new HttpState(); HttpClient httpclient = new HttpClient(); httpclient.setState(initialState); httpclient.getParams().setCookiePolicy(CookiePolicy.NETSCAPE);

HttpWebRequest POST data

梦想的初衷 提交于 2019-12-23 03:04:22
问题 Is it possible to make an exact identical POST with HttpWebRequest in C# as a browser would? Without a page being able to detect that it is actually no browser? If so, were could i read up more on that? 回答1: Download and become familiar with a tool like Fiddler. It allows you to inspect web requests made from applications, like a normal browser, and see exactly what is being sent. You can then emulate the data being sent with a request created in C#, providing values for headers, cookies, etc

Validate request before Application_BeginRequest?

▼魔方 西西 提交于 2019-12-23 02:58:21
问题 I trying to perform aditional validation before application start reading the input of the request, to end suspicious request, based on headers and form data or something like that. Is there it possible? [Update] I'm focusing in prevent a zero day vunerability that occurs before BeginRequest and ins't catch by ASP .net validation. If I could control the creation of the HttpWebRequest object I could detect this attack. [Solution] It can be solved using a native module. Information about a

HttpWebRequest Unable to download data from nasdaq.com but able from browsers

落花浮王杯 提交于 2019-12-23 02:45:35
问题 I am trying to download this website csv file, the file small only take like 2 seconds to download with any browsers. http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=AMEX&render=download using HttpWebRequest and also WebClient but looks like nasdaq.com is not letting the data to flow through with these two methods, I also tried with Fiddler and nothing coming back. I only can download this data using any browsers. I tried to change the header, the agent, security

Why my httpwebrequest post to myhandler.ashx is rejected with status code 401

前提是你 提交于 2019-12-23 02:38:28
问题 I've already written an HTTPHandler that gets POSTed from a ColdFusion page and it works successfully; now, I am trying to write a web application in ASP.NET so I can post a form to the .ashx handler from an .aspx page. Application Trace (trace.axd) shows the following as my last 3 entries: 2 8/14/2009 1:53:56 PM /Default.aspx 200 GET View Details 3 8/14/2009 1:54:04 PM /Default.aspx 200 POST View Details 4 8/14/2009 1:54:13 PM /UploadHandler.ashx 401 POST View Details I have a breakpoint in

HttpWebRequest only works while fiddler is running

和自甴很熟 提交于 2019-12-23 01:54:28
问题 I'm having some issues with the following code. It'll run fine when Fiddler is on, but it times out when Fiddler isn't running. IWebProxy proxy = websiterequester.Proxy; websiterequester = (HttpWebRequest)WebRequest.Create("http://website.com/"); websiterequester.CookieContainer = cookieJar; websiterequester.Method = "GET"; websiterequester.Referer = "http://website.com/"; if (websiterequester.Proxy != null) { websiterequester.Proxy = null; } try { objStream1 = websiterequester.GetResponse()