I try to construct WebRequest to a web page after successful logging in to secured web portal via WPF WebBrowser control, but stuck with the problem of reusing WebBrowser cookies in WebRequest.
Unlike WinForms, in WPF WebBrowser control there is no way to extract CookieCollection via WebBrowser.Document.Cookies because Document object does not have Cookies property. The only way I found is to use mshtml.HTMLDocument2 which has cookies as string
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)webBrowser.Document;
string cookies = doc.cookie;
However it is not good enough as looks like MSHTML.Document2 - does not allow to extract important HttpOnly cookies (like ASP.Net_SessionID) - and I need manually construct CookiesCollection object from Cookies string.
As a result, WebRequest with cookies constructed from string is failing with Session timeout error as ASP.Net_SessionID is not available.
Is there another way of building proper and completed CookieCollection object from WPF WebBrowser control?