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

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript