WebBroswer query in Windows Phone

妖精的绣舞 提交于 2020-01-06 14:32:26

问题


I've got the following code, but when I Build it I get an error on WebBrowserDocumentCompletedEventArgs telling me the type or namespace could not be found.

I've been searching the web and attempting to add DLLs for over an hour. Can anyone help?

private void b_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        WebBrowser b = sender as WebBrowser;
        string response = b.DocumentText;

        // looks in the page source to find the authenticity token.
        // could also use regular exp<b></b>ressions here.
        int index = response.IndexOf("authenticity_token");
        int startIndex = index + 41;
        string authenticityToken = response.Substring(startIndex, 40);

        // unregisters the first event handler
        // adds a second event handler
        b.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(b_DocumentCompleted);
        b.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(b_DocumentCompleted2);

        // format our data that we are going to post to the server
        // this will include our post parameters.  They do not need to be in a specific
        //  order, as long as they are concatenated together using an ampersand ( & )
        string postData = string.Format("authenticity_token={2}&session[username_or_email]={0}&session[password]={1}&commit={3}", username, password, authenticityToken, commit);

        ASCIIEncoding enc = new ASCIIEncoding();

        //  we are encoding the postData to a byte array
        b.Navigate("https://twitter.com/sessions", "", enc.GetBytes(postData), "Content-Type: application/x-www-form-urlencoded\r\n");
    }

来源:https://stackoverflow.com/questions/23438905/webbrowserdocumentcompletedeventhandler-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!