简体   繁体   English

C#桌面应用程序中的弹出窗口和Web uri

[英]Popup and web uri within c# desktop application

I need to access some web api from my desktop application for authentication. 我需要从桌面应用程序访问一些Web API进行身份验证。 For example, facebook api, it requires to redirect to facebook page for allow permission from user and then it redirect back along with an access token which is needed for accessing private data. 例如,facebook api,它需要重定向到facebook页面以允许来自用户的许可,然后再重定向回访问令牌,该令牌是访问私有数据所需的。 Now, on facebook documentation they alreasy metioned that, webbrowser class of .NET framework can help in this case. 现在,在Facebook文档上,他们很容易提到,.NET框架的webbrowser类可以在这种情况下提供帮助。 THere are two webbrowser class, one for wpf application, at msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.aspx, another is for windows forms application, at msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx 这是两个webbrowser类,一个用于wpf应用程序,位于msdn.microsoft.com/zh-cn/library/system.windows.controls.webbrowser.aspx,另一个用于Windows窗体应用程序,位于msdn.microsoft.com/zh-我们/library/system.windows.forms.webbrowser.aspx

Now, My question is, how can i use this to make a broser like popup of the url and after it back , retrieve the url again. 现在,我的问题是,我该如何使用它来制作一个类似URL弹出窗口的浏览器,然后将其返回,再次检索URL。

Regards 问候

Well, I will list the steps for you, and it's easier that you may think: 好吧,我将为您列出这些步骤,您可能会更容易想到:

  • Create a new Form that will be used to house the WebBrowser control and style it to look like a popup. 创建一个新Form ,该Form将用于容纳WebBrowser控件并设置其样式以使其看起来像弹出窗口。
  • Add the WebBrowser to the form - by default, this will fill the entire forms layout 将WebBrowser添加到表单-默认情况下,这将填充整个表单布局
  • Use the Navigate() method on the WebBrowser to go to the needed URL 使用WebBrowser上的Navigate()方法转到所需的URL
  • Once the user has clicked the button, check the Url property on the WebBrowser and get the token (Hint: you can use the Navigated event to determine when the page is (re)loading.) 用户单击按钮后,检查WebBrowser上的Url属性并获取令牌(提示:您可以使用Navigated事件来确定何时(重新)加载页面。)

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

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