I have cookies which taken from HttpWebRequest and I need to set these cookies to WebView control to another page.
How can I transfer these cookie to WebView control in windows 8.1 Store app?
I got an answer on MSDN and it works well for me.
try
{
Uri baseUri = new Uri(txtURI.Text);
Windows.Web.Http.Filters.HttpBaseProtocolFilter filter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
Windows.Web.Http.HttpCookie cookie = new Windows.Web.Http.HttpCookie("cookieName", baseUri.Host, "/");
cookie.Value = "cookieValue";
filter.CookieManager.SetCookie(cookie, false);
Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Get, baseUri);
wvTest.NavigateWithHttpRequestMessage(httpRequestMessage);
}
catch (Exception oEx)
{
// handle exception
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With