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

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?