简体   繁体   English

WebBrowser控件:导航到网页已取消

[英]WebBrowser control: Navigation to the webpage was canceled

Setup 设定

  • Windows 8 (full) tablet Windows 8(完整)平板电脑
  • .NET 2.0 application .NET 2.0应用程序

I'm working on a project in which 4 WebBrowser controls are navigating to some webpage simultaneously when the application is loaded. 我正在开发一个项目,其中4个WebBrowser控件在加载应用程序时同时导航到某个网页。 The webpages have the same HTML, but are coming from different web servers. 网页具有相同的HTML,但来自不同的Web服务器。

The problem is that some of those pages display a "Navigation to the webpage was canceled" message in the WebBrowser control. 问题是其中一些页面在WebBrowser控件中显示“导航到网页已取消”消息。 This only happens when the application starts. 这仅在应用程序启动时发生。 I have implemented the solution described here to get the status code returned and weirdly enough, it is a 200 = OK status. 我已经实现了这里描述的解决方案来获取返回的状态代码,奇怪的是,它是200 = OK状态。

When I then refresh the page, it suddenly works correctly. 当我刷新页面时,它突然正常工作。 I have suspicions that the problem might be caused by the simultaneous navigations, but I have no idea how I could verify that. 我怀疑问题可能是由同时导航造成的,但我不知道如何验证这一点。

Any ideas? 有任何想法吗?

Alright, so I ended up firing a navigation and waiting for it to complete before doing the next one and I haven't encountered the problem since. 好吧,所以我最后发射导航并等待它完成下一个之前我没有遇到问题。 It was a problem that didn't need a fancy solution, and we didn't have time to dig deeper, so we went with that. 这是一个不需要花哨的解决方案的问题,我们没有时间深入挖掘,所以我们接受了。

A case of Facebook Login using OAuth: 使用OAuth进行Facebook登录的案例:

It worked for me navigating from WPF WebBrowser to: 它适用于我从WPF WebBrowser导航到:

https://graph.facebook.com/oauth/authorize?client_id=zzzzzzzzzzzzzzzz&redirect_uri=https://www.facebook.com/connect/login_success.html&type=user_agent&display=popup

Than something changed and I get: Navigation to the webpage was cancelled 比改变了什么,我得到了: 导航到网页被取消了

From Chrome I can see the reason: 从Chrome我可以看到原因:

{
   "error": {
      "message": "Can't load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and sub-domains of your app to the App Domains field in your app settings.",
      "type": "OAuthException",
      "code": 191,
      "fbtrace_id": "GuhAfeO/85U"
   }
}

Why happened? 为什么发生?

The link above works only for empty "Valid OAuth Redirect URIs". 上面的链接仅适用于空的“有效OAuth重定向URI”。 When a URL was added to support a website login, the app stopped working. 添加URL以支持网站登录时,应用程序停止工作。

I went to my settings and removed the url. 我去了我的设置并删除了网址。 Works now! 现在就行! https://developers.facebook.com/apps/zzzzzzzzzzzzzz/fb-login/settings/ https://developers.facebook.com/apps/zzzzzzzzzzzzzz/fb-login/settings/

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

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