简体   繁体   English

如何在我的Web浏览器控件中添加cookie?

[英]How to add cookie in my web browser control?

I want to add cookie in my web browser control. 我想在我的网络浏览器控件中添加cookie。

webBrowser1.Navigate(new Uri(serverUrl)); 

Basically i need to put cookie value at the time of the navigation.How can i add cookie to this type request in windows phone 7 基本上我需要在导航时输入cookie值。如何在Windows Phone 7中为此类型请求添加cookie

Let me explain my complete problem. 让我解释一下我的完整问题。

I have to send an Authentication key through cookies to the webrequest for the server to authenticate the client. 我必须通过cookie将身份验证密钥发送到webrequest,以便服务器对客户端进行身份验证。 In mobile devices like Android and iPhone, they have a Cookie container where the browser control takes the data from the cookie container. 在Android和iPhone等移动设备中,它们有一个Cookie容器,浏览器控件从cookie容器中获取数据。 I expected WP7 to have similar facility, but I didnot find it. 我期望WP7有类似的设施,但我没有找到它。 (Did I miss it ? if so please direct me.) (我错过了吗?如果有,请指导我。)

Please help me...Thanks 请帮帮我...谢谢

I am not sure this will work or not. 我不确定这是否有效。 But you can call JavaScript functions inside a page from C# using Web Browser control and in JavaScript you can set the cookie. 但您可以使用Web浏览器控件在C#中调用页面内的JavaScript函数,在JavaScript中可以设置cookie。 To call JavaScript functions of Web Browser controls see the link below. 要调用Web浏览器控件的JavaScript函数,请参阅下面的链接。

 webBrowser1.Document.InvokeScript(jsfunctionname, parameters);

http://notions.okuda.ca/2009/06/11/calling-javascript-in-a-webbrowser-control-from-c/ http://notions.okuda.ca/2009/06/11/calling-javascript-in-a-webbrowser-control-from-c/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM