Reputation: 33
I need to do a LoadRequest(request) with postdata in CEFSharp. I was using the IE Navigate but wanting to switch over to CEFSharp so I found a Navigate function for CEFSharp.
public void Navigate (string url, byte[] postDataBytes, string contentType)
{
IFrame frame = eRXWebBrowser.GetMainFrame ();
IRequest request = frame.CreateRequest (initializePostData: true);
request.Url = url;
request.Method = "POST";
//request.InitializePostData ();
var element = request.PostData.CreatePostDataElement ();
element.Bytes = postDataBytes;
var status = request.PostData.AddElement (element);
NameValueCollection headers = new NameValueCollection
{
{"Content-Type", contentType}
};
request.Headers = headers;
frame.LoadRequest (request);
}
I call this in the Load event for the ViewModel but nothing happens. I feel like I am close but just missing something. Cannot find info on when to call the LoadRequest(). I am using CEFSharp version 65 and I have tried loading a webpage before the Load event and the webpage shows fine. Thanks for any help.
Upvotes: 1
Views: 1118