The Older post that I’ve made 30 minuts ago has seen all its responses deleted.. First of all I want to apologize for my English to all the moderator that have corrected me each time I wrote something on this forum :).
Ok so basicaly the problem is that I need to add a token in my WebBrowser Cookies for a bank-app done mostly with webviews.
I’ve written a test web page that displays the cookies. and I try to hit it like so:
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
string testCookies = "http://devlbpaccescomptewp7.clicmobile.com/test-read-cookie.html?timeStamp=";
testCookies += DateTime.Now.Millisecond;
Cookie cookie = new Cookie("cookie", "lol");
Uri test = new Uri(testCookies, UriKind.Absolute);
CookieContainer cc = new CookieContainer();
cc.Add(test,cookie);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(testCookies);
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;)";
req.Method = "POST";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
req.CookieContainer = cc;
//HttpWebResponse myWebResponse = (HttpWebResponse)req.get
req.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), req);
uriList = new List<Uri>();
// wB.Navigate(test);
// wB.Navigate(new Uri(home, UriKind.Absolute));
wB.Navigating += new EventHandler<NavigatingEventArgs>(wB_Navigating);
}
private void ReadWebRequestCallback(IAsyncResult callbackResult)
{
HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult);
using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
{
string results = httpwebStreamReader.ReadToEnd();
Deployment.Current.Dispatcher.BeginInvoke(() => wB.NavigateToString(results));
}
myResponse.Close();
}
I got an UnauthorizedAccessExeption on the wb.NavigateToString line.
Does somebody has already seen that ?
Thanks,
Renaud
EDIT : I corrected the conserned line to make it work !
Since your callback is on a different thread, you need to use the Dispatcher to modify the UI.