You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by rpriest1260 September 30, 2024
Hello,
I am seeing an issue and wondering if this is a bug in the WebView2 code. Essentially, after the BasicAuthenticationRequested event fires and the credentials are supplied, the WebView2 code appears to remove the Content-Type header (if supplied), from the initial POST request sent. The webservice I intend to use needs that header, so this breaks the request. Should I file a bug for it? Has anyone else run into this?
Just to check I created the same POST request with a HttpWebRequest, object, and that does not have this problem - it does not strip the Content-Type header after the 407-Proxy Auth Required has been satisfied with the supplied credentials.
I am using:
.NET 4.7.2
WebView2 1.0.2792.45
Proxy Server - with Proxy Authentication Required (I am testing with Fiddler Classic).
And my credentials are supplied using the BasicAuthenticationRequired even, like so
webView.CoreWebView2.BasicAuthenticationRequested+=(s,args)=>{//var creds = new {UserName="1", Password="1"};varcreds=(webProxy==null||string.IsNullOrEmpty(webProxy?.Address.ToString()))?null:webProxy?.CredentialsasNetworkCredential;if(creds!=null){s_logger.Debug($"Setting proxy creds. User = {creds.UserName}");args.Response.UserName=creds.UserName;args.Response.Password=creds.Password;}};
And as mentioned, above, A basic HttpWebRequest, does not have this issue. If you would like to see what code I used to compare to WebView2, it looks like this:
HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(url);WebProxymyProxy=newWebProxy();// Associate the newUri object to 'myProxy' object so that new myProxy settings can be set.myProxy.Address=newUri("http://localhost:9191");// Create a NetworkCredential object and associate it with the // Proxy property of request object.myProxy.Credentials=newNetworkCredential("1","1");request.Proxy=myProxy;request.Method="POST";ASCIIEncodingencoding=newASCIIEncoding();request.ContentType="application/x-www-form-urlencoded";byte[]data=encoding.GetBytes("data1=postdatastring_fff");request.ContentLength=data.Length;StreamnewStream=request.GetRequestStream();//open connectionnewStream.Write(data,0,data.Length);// Send the data.newStream.Close();stringtext;varresponse=(HttpWebResponse)request.GetResponse();
if any other information or sample code is needed, please just ask and I will supply.
Thank you in advance.
The text was updated successfully, but these errors were encountered:
Discussed in #4841
Originally posted by rpriest1260 September 30, 2024
Hello,
I am seeing an issue and wondering if this is a bug in the WebView2 code. Essentially, after the BasicAuthenticationRequested event fires and the credentials are supplied, the WebView2 code appears to remove the Content-Type header (if supplied), from the initial POST request sent. The webservice I intend to use needs that header, so this breaks the request. Should I file a bug for it? Has anyone else run into this?
Just to check I created the same POST request with a HttpWebRequest, object, and that does not have this problem - it does not strip the Content-Type header after the 407-Proxy Auth Required has been satisfied with the supplied credentials.
I am using:
My POST request is done as follows:
And my credentials are supplied using the BasicAuthenticationRequired even, like so
And as mentioned, above, A basic HttpWebRequest, does not have this issue. If you would like to see what code I used to compare to WebView2, it looks like this:
if any other information or sample code is needed, please just ask and I will supply.
Thank you in advance.
The text was updated successfully, but these errors were encountered: