Xamarin form: WkWebView not loading websiteLoaded nib but the 'view' outlet was not setneed help for webviewDoes anyone have benchmarks (code & results) comparing performance of Android apps written in Xamarin C# and Java?Xamarin 2.0 vs Appcelerator Titanium vs PhoneGapParse push json IOS webviewXamarin Forms - Webview - Remote Website - Load included javascript fileWhat's the difference between .NET Core, .NET Framework, and Xamarin?Xamarin WKWebView Accepting Self-Signed CertificatesDisposing a WKWebView in XamarinURL is not loading in WKWebView Xamarin

Array Stutter Implementation

Why does the 6502 have the BIT instruction?

Would the Geas spell work in a dead magic zone once you enter it?

Is there a way to make it so the cursor is included when I prtscr key?

Can a wire having a 610-670 THz (frequency of blue light) AC frequency supply, generate blue light?

What is the largest (size) solid object ever dropped from an airplane to impact the ground in freefall?

When and what was the first 3D acceleration device ever released?

Mother abusing my finances

Why is desire the root of suffering?

LASSO Regression - p-values and coefficients

Where is the logic in castrating fighters?

Should I disclose a colleague's illness (that I should not know about) when others badmouth him

I think I may have violated academic integrity last year - what should I do?

What is the 中 in ダウンロード中?

Windows 10 Programs start without visual Interface

What are the benefits of cryosleep?

Why do airplanes use an axial flow jet engine instead of a more compact centrifugal jet engine?

If a person had control of every single cell of their body, would they be able to transform into another creature?

Employer demanding to see degree after poor code review

Python program to convert a 24 hour format to 12 hour format

Ticket sales for Queen at the Live Aid

Rests in pickup measure (anacrusis)

How were these pictures of spacecraft wind tunnel testing taken?

ESTA/WVP - leaving US within 90 days, then staying in DR



Xamarin form: WkWebView not loading website


Loaded nib but the 'view' outlet was not setneed help for webviewDoes anyone have benchmarks (code & results) comparing performance of Android apps written in Xamarin C# and Java?Xamarin 2.0 vs Appcelerator Titanium vs PhoneGapParse push json IOS webviewXamarin Forms - Webview - Remote Website - Load included javascript fileWhat's the difference between .NET Core, .NET Framework, and Xamarin?Xamarin WKWebView Accepting Self-Signed CertificatesDisposing a WKWebView in XamarinURL is not loading in WKWebView Xamarin






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Hi am using the Sample code from Xamarin (Hybrid WebView)



public class Test : WKNavigationDelegate

public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)





public class HybridWebViewRenderer : ViewRenderer<HybridWebView, WKWebView>, IWKScriptMessageHandler

const string JavaScriptFunction = "function invokeCSharpAction(data)window.webkit.messageHandlers.invokeAction.postMessage(data);";
WKUserContentController userController;

protected override void OnElementChanged (ElementChangedEventArgs<HybridWebView> e)

base.OnElementChanged (e);

if (Control == null)
userController = new WKUserContentController ();
var script = new WKUserScript (new NSString (JavaScriptFunction), WKUserScriptInjectionTime.AtDocumentEnd, false);
userController.AddUserScript (script);
userController.AddScriptMessageHandler (this, "invokeAction");

var config = new WKWebViewConfiguration UserContentController = userController ;
config.WebsiteDataStore = WKWebsiteDataStore.DefaultDataStore;

var webView = new WKWebView (Frame, config);
webView.NavigationDelegate = new Test();
SetNativeControl (webView);

if (e.OldElement != null)
userController.RemoveAllUserScripts ();
userController.RemoveScriptMessageHandler ("invokeAction");
var hybridWebView = e.OldElement as HybridWebView;
hybridWebView.Cleanup ();

if (e.NewElement != null)
string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", "index.html"));
Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));





public void DidReceiveScriptMessage (WKUserContentController userContentController, WKScriptMessage message)

Element.InvokeAction (message.Body.ToString ());




The code can run the html file stored locally in the Content folder in the app. When I change to new NSUrlRequest (new NSUrl ("http://www.google.com", false))); The page is blank.










share|improve this question




























    0















    Hi am using the Sample code from Xamarin (Hybrid WebView)



    public class Test : WKNavigationDelegate

    public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)





    public class HybridWebViewRenderer : ViewRenderer<HybridWebView, WKWebView>, IWKScriptMessageHandler

    const string JavaScriptFunction = "function invokeCSharpAction(data)window.webkit.messageHandlers.invokeAction.postMessage(data);";
    WKUserContentController userController;

    protected override void OnElementChanged (ElementChangedEventArgs<HybridWebView> e)

    base.OnElementChanged (e);

    if (Control == null)
    userController = new WKUserContentController ();
    var script = new WKUserScript (new NSString (JavaScriptFunction), WKUserScriptInjectionTime.AtDocumentEnd, false);
    userController.AddUserScript (script);
    userController.AddScriptMessageHandler (this, "invokeAction");

    var config = new WKWebViewConfiguration UserContentController = userController ;
    config.WebsiteDataStore = WKWebsiteDataStore.DefaultDataStore;

    var webView = new WKWebView (Frame, config);
    webView.NavigationDelegate = new Test();
    SetNativeControl (webView);

    if (e.OldElement != null)
    userController.RemoveAllUserScripts ();
    userController.RemoveScriptMessageHandler ("invokeAction");
    var hybridWebView = e.OldElement as HybridWebView;
    hybridWebView.Cleanup ();

    if (e.NewElement != null)
    string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", "index.html"));
    Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));





    public void DidReceiveScriptMessage (WKUserContentController userContentController, WKScriptMessage message)

    Element.InvokeAction (message.Body.ToString ());




    The code can run the html file stored locally in the Content folder in the app. When I change to new NSUrlRequest (new NSUrl ("http://www.google.com", false))); The page is blank.










    share|improve this question
























      0












      0








      0








      Hi am using the Sample code from Xamarin (Hybrid WebView)



      public class Test : WKNavigationDelegate

      public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)





      public class HybridWebViewRenderer : ViewRenderer<HybridWebView, WKWebView>, IWKScriptMessageHandler

      const string JavaScriptFunction = "function invokeCSharpAction(data)window.webkit.messageHandlers.invokeAction.postMessage(data);";
      WKUserContentController userController;

      protected override void OnElementChanged (ElementChangedEventArgs<HybridWebView> e)

      base.OnElementChanged (e);

      if (Control == null)
      userController = new WKUserContentController ();
      var script = new WKUserScript (new NSString (JavaScriptFunction), WKUserScriptInjectionTime.AtDocumentEnd, false);
      userController.AddUserScript (script);
      userController.AddScriptMessageHandler (this, "invokeAction");

      var config = new WKWebViewConfiguration UserContentController = userController ;
      config.WebsiteDataStore = WKWebsiteDataStore.DefaultDataStore;

      var webView = new WKWebView (Frame, config);
      webView.NavigationDelegate = new Test();
      SetNativeControl (webView);

      if (e.OldElement != null)
      userController.RemoveAllUserScripts ();
      userController.RemoveScriptMessageHandler ("invokeAction");
      var hybridWebView = e.OldElement as HybridWebView;
      hybridWebView.Cleanup ();

      if (e.NewElement != null)
      string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", "index.html"));
      Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));





      public void DidReceiveScriptMessage (WKUserContentController userContentController, WKScriptMessage message)

      Element.InvokeAction (message.Body.ToString ());




      The code can run the html file stored locally in the Content folder in the app. When I change to new NSUrlRequest (new NSUrl ("http://www.google.com", false))); The page is blank.










      share|improve this question














      Hi am using the Sample code from Xamarin (Hybrid WebView)



      public class Test : WKNavigationDelegate

      public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)





      public class HybridWebViewRenderer : ViewRenderer<HybridWebView, WKWebView>, IWKScriptMessageHandler

      const string JavaScriptFunction = "function invokeCSharpAction(data)window.webkit.messageHandlers.invokeAction.postMessage(data);";
      WKUserContentController userController;

      protected override void OnElementChanged (ElementChangedEventArgs<HybridWebView> e)

      base.OnElementChanged (e);

      if (Control == null)
      userController = new WKUserContentController ();
      var script = new WKUserScript (new NSString (JavaScriptFunction), WKUserScriptInjectionTime.AtDocumentEnd, false);
      userController.AddUserScript (script);
      userController.AddScriptMessageHandler (this, "invokeAction");

      var config = new WKWebViewConfiguration UserContentController = userController ;
      config.WebsiteDataStore = WKWebsiteDataStore.DefaultDataStore;

      var webView = new WKWebView (Frame, config);
      webView.NavigationDelegate = new Test();
      SetNativeControl (webView);

      if (e.OldElement != null)
      userController.RemoveAllUserScripts ();
      userController.RemoveScriptMessageHandler ("invokeAction");
      var hybridWebView = e.OldElement as HybridWebView;
      hybridWebView.Cleanup ();

      if (e.NewElement != null)
      string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", "index.html"));
      Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));





      public void DidReceiveScriptMessage (WKUserContentController userContentController, WKScriptMessage message)

      Element.InvokeAction (message.Body.ToString ());




      The code can run the html file stored locally in the Content folder in the app. When I change to new NSUrlRequest (new NSUrl ("http://www.google.com", false))); The page is blank.







      ios xamarin webview






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 7:21









      LittleFunnyLittleFunny

      3,055748110




      3,055748110






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Solution:



          Have a look at this part of code in custom renderer:



          if (e.NewElement != null) 
          string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", "index.html"));
          Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));



          The url here is combining a local path in the app. So, it will load a local Html successfully and won't work when your change to new NSUrlRequest (new NSUrl ("http://www.google.com", false))).



          So, if you want to load a website, you should change the code to :



          if (e.NewElement != null) 
          //string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", Element.Uri));
          //Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));

          //test
          //Control.LoadRequest(new NSUrlRequest(new NSUrl("https://preview.pro.ant.design/user/login")));

          Control.LoadRequest (new NSUrlRequest (new NSUrl (Element.Uri)));






          share|improve this answer

























          • @LittleFunny Glad to hear that. I answered another your question about webView appears blank before, the same cause as here?

            – Jack Hua - MSFT
            Mar 25 at 7:58











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321569%2fxamarin-form-wkwebview-not-loading-website%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Solution:



          Have a look at this part of code in custom renderer:



          if (e.NewElement != null) 
          string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", "index.html"));
          Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));



          The url here is combining a local path in the app. So, it will load a local Html successfully and won't work when your change to new NSUrlRequest (new NSUrl ("http://www.google.com", false))).



          So, if you want to load a website, you should change the code to :



          if (e.NewElement != null) 
          //string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", Element.Uri));
          //Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));

          //test
          //Control.LoadRequest(new NSUrlRequest(new NSUrl("https://preview.pro.ant.design/user/login")));

          Control.LoadRequest (new NSUrlRequest (new NSUrl (Element.Uri)));






          share|improve this answer

























          • @LittleFunny Glad to hear that. I answered another your question about webView appears blank before, the same cause as here?

            – Jack Hua - MSFT
            Mar 25 at 7:58















          0














          Solution:



          Have a look at this part of code in custom renderer:



          if (e.NewElement != null) 
          string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", "index.html"));
          Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));



          The url here is combining a local path in the app. So, it will load a local Html successfully and won't work when your change to new NSUrlRequest (new NSUrl ("http://www.google.com", false))).



          So, if you want to load a website, you should change the code to :



          if (e.NewElement != null) 
          //string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", Element.Uri));
          //Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));

          //test
          //Control.LoadRequest(new NSUrlRequest(new NSUrl("https://preview.pro.ant.design/user/login")));

          Control.LoadRequest (new NSUrlRequest (new NSUrl (Element.Uri)));






          share|improve this answer

























          • @LittleFunny Glad to hear that. I answered another your question about webView appears blank before, the same cause as here?

            – Jack Hua - MSFT
            Mar 25 at 7:58













          0












          0








          0







          Solution:



          Have a look at this part of code in custom renderer:



          if (e.NewElement != null) 
          string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", "index.html"));
          Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));



          The url here is combining a local path in the app. So, it will load a local Html successfully and won't work when your change to new NSUrlRequest (new NSUrl ("http://www.google.com", false))).



          So, if you want to load a website, you should change the code to :



          if (e.NewElement != null) 
          //string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", Element.Uri));
          //Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));

          //test
          //Control.LoadRequest(new NSUrlRequest(new NSUrl("https://preview.pro.ant.design/user/login")));

          Control.LoadRequest (new NSUrlRequest (new NSUrl (Element.Uri)));






          share|improve this answer















          Solution:



          Have a look at this part of code in custom renderer:



          if (e.NewElement != null) 
          string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", "index.html"));
          Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));



          The url here is combining a local path in the app. So, it will load a local Html successfully and won't work when your change to new NSUrlRequest (new NSUrl ("http://www.google.com", false))).



          So, if you want to load a website, you should change the code to :



          if (e.NewElement != null) 
          //string fileName = Path.Combine (NSBundle.MainBundle.BundlePath, string.Format ("Content/0", Element.Uri));
          //Control.LoadRequest (new NSUrlRequest (new NSUrl (fileName, false)));

          //test
          //Control.LoadRequest(new NSUrlRequest(new NSUrl("https://preview.pro.ant.design/user/login")));

          Control.LoadRequest (new NSUrlRequest (new NSUrl (Element.Uri)));







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 25 at 6:48

























          answered Mar 25 at 6:43









          Jack Hua - MSFTJack Hua - MSFT

          2,2301210




          2,2301210












          • @LittleFunny Glad to hear that. I answered another your question about webView appears blank before, the same cause as here?

            – Jack Hua - MSFT
            Mar 25 at 7:58

















          • @LittleFunny Glad to hear that. I answered another your question about webView appears blank before, the same cause as here?

            – Jack Hua - MSFT
            Mar 25 at 7:58
















          @LittleFunny Glad to hear that. I answered another your question about webView appears blank before, the same cause as here?

          – Jack Hua - MSFT
          Mar 25 at 7:58





          @LittleFunny Glad to hear that. I answered another your question about webView appears blank before, the same cause as here?

          – Jack Hua - MSFT
          Mar 25 at 7:58

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321569%2fxamarin-form-wkwebview-not-loading-website%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현