webrequest

C# WebRequest using Cookies

跟風遠走 提交于 2019-11-26 17:45:07
问题 I have a winforms application i have been working on that runs multiple tests on consumer accounts. The tests require a one time login in order to execute. string paramaters = "authmethod=on&chkRememberMe=on&login-form-type=pwd&password=" + pw.Text + "&userid=" + uid.Text + "&username=" + uid.Text; string strResponse; HttpWebRequest requestLogin = (HttpWebRequest)WebRequest.Create("https://www.url.com/login.form"); requestLogin.Method = "POST"; requestLogin.CookieContainer = cookieJar;

Mono https webrequest fails with “The authentication or decryption has failed”

可紊 提交于 2019-11-26 17:34:40
I'm making a simple REST client to use in my C# applications. In .net on Windows It works great with http:// and https:// connections. In mono 2.6.7 (Also tested with 2.8 with the same results) on Ubuntu 10.10 only http:// works. https:// connections throw up this exception on the request.GetResponse() method: Unhandled Exception: System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate

Creating WPF BitmapImage from MemoryStream png, gif

删除回忆录丶 提交于 2019-11-26 16:25:47
I am having some trouble creating a BitmapImage from a MemoryStream from png and gif bytes obtained from a web request. The bytes seem to be downloaded fine and the BitmapImage object is created without issue however the image is not actually rendering on my UI. The problem only occurs when the downloaded image is of type png or gif (works fine for jpeg). Here is code that demonstrates the problem: var webResponse = webRequest.GetResponse(); var stream = webResponse.GetResponseStream(); if (stream.CanRead) { Byte[] buffer = new Byte[webResponse.ContentLength]; stream.Read(buffer, 0, buffer

Cannot set some HTTP headers when using System.Net.WebRequest

╄→尐↘猪︶ㄣ 提交于 2019-11-26 15:49:30
When I try to add a HTTP header key/value pair on a WebRequest object, I get the following exception: This header must be modified using the appropriate property I've tried adding new values to the Headers collection by using the Add() method but I still get the same exception. webRequest.Headers.Add(HttpRequestHeader.Referer, "http://stackoverflow.com"); I can get around this by casting the WebRequest object to a HttpWebRequest and setting the properties such as httpWebReq.Referer ="http://stackoverflow.com" , but this only works for a handful of headers that are exposed via properties. I'd

HttpWebRequest to URL with dot at the end

左心房为你撑大大i 提交于 2019-11-26 14:37:28
when i do a GET with WebRequest.Create(" http://abc/test .") i get 404 because according to fiddler the trailing dot gets stripped away by .NET and the web server needs the dot. how can i prevent that or work around it. any workaround is appreciated! Workaround in workaround tab at the official bug report: https://connect.microsoft.com/VisualStudio/feedback/details/386695/system-uri-incorrectly-strips-trailing-dots?wa=wsignin1.0#tabs .. seems to be valid. Basically, run this code to reset a static flag in .NET before working with System.Uri: MethodInfo getSyntax = typeof(UriParser).GetMethod(

Making a web request to a web page which requires windows authentication

纵然是瞬间 提交于 2019-11-26 14:11:44
问题 I am trying to make a request to a web page using WebRequest class in .net. The url that I am trying to read requires Windows Authentication due to which I get an unauthorised exception. How can I pass a windows credentials to this request so that it can authenticate. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create( "http://myapp/home.aspx" ); request.Method = "GET"; request.UseDefaultCredentials = false; request.PreAuthenticate = true; request.Credentials = new

Can I send webrequest from specified ip address with .NET Framework?

荒凉一梦 提交于 2019-11-26 13:53:49
问题 I have a server with multi ip addresses. Now I need to communicate with several servers with http protocol. Each server only accept the request from a specified ip address of my server. But when using WebRequest(or HttpWebRequest) in .NET , the request object will choose a ip address automatically. I can't find anyway to bind the request with a address. Is there anyway to do so ? Or I have to implement a webrequest class myself ? 回答1: You need to use the ServicePoint.BindIPEndPointDelegate

Which versions of SSL/TLS does System.Net.WebRequest support?

你。 提交于 2019-11-26 11:53:10
问题 Now that SSL 3 has been found to be vulnerable to the POODLE attack: Which versions of SSL/TLS does System.Net.WebRequest use when connecting to any https Uri? I use WebRequest to connect to several 3rd party API\'s. One of these has now said they will block any request that uses SSL 3. But WebRequest is part of the .Net core framework (using 4.5) so it is not obvious what version it uses. 回答1: When using System.Net.WebRequest your application will negotiate with the server to determine the

HttpWebRequest using Basic authentication

老子叫甜甜 提交于 2019-11-26 11:40:29
I'm trying to go through an authentication request that mimics the "basic auth request" we're used to seeing when setting up IIS for this behavior. The URL is: https://telematicoprova.agenziadogane.it/TelematicoServiziDiUtilitaWeb/ServiziDiUtilitaAutServlet?UC=22&SC=1&ST=2 (warning: https!) This server is running under UNIX and Java as application server. This is the code I use to connect to this server: CookieContainer myContainer = new CookieContainer(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://telematicoprova.agenziadogane.it/TelematicoServiziDiUtilitaWeb

C# - How to make a HTTP call

旧街凉风 提交于 2019-11-26 09:47:11
问题 I wanted to make an HTTP call to a website. I just need to hit the URL and dont want to upload or download any data. What is the easiest and fastest way to do it. I tried below code but its slow and after 2nd repetitive request it just goes into timeout for 59 secounds and than resume: WebRequest webRequest = WebRequest.Create(\"http://ussbazesspre004:9002/DREADD?\" + fileName); webRequest.Method = \"POST\"; webRequest.ContentType = \"application/x-www-form-urlencoded\"; webRequest