我在 30 分钟前发布的旧帖子已删除所有回复。首先,我想为我的英语向所有版主道歉,因为我每次在这个论坛上写东西时都纠正了我 :)。
好的,基本上问题是我需要在我的 WebBrowser Cookies 中添加一个令牌,用于主要使用 webviews 完成的银行应用程序。我编写了一个显示 cookie 的测试网页。我试着这样击球:
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();
}
我在 wb.NavigateToString 行上得到了 UnauthorizedAccessExeption。
有人已经看到了吗?
谢谢,雷诺
编辑:我更正了 conserned 线以使其工作!