Forum Xamarin.iOS

IoS 12 update: WKWebView custom renderer issue

saguarsaguar ITMember

Hi all,
I'm facing with a very weird issue with a Xamarin Forms application on IoS after the latest OS update. Basically this application uses a WebView renderer to navigate a company's intranet portal which has NTLM authentication. I implemented the web renderer to handle the authentication process and it was working fine till few week ago but after Apple's last update the webview has stopped working.
Unfortunately there is no error code, exception or explicit message from the SDK, and the authentication process is working (I can see it from the logs), by the way the webview's content is all blank.
I have tried to navigate to other websites (with no authentication) too (,, but the issue was still there.

Anyone has some suggestion or hint?


  • saguarsaguar ITMember


    After a deep investigation I've finally found the problem! Actually it seems that after the deprecation of UIWebview when using a custom renderer to handle authentication scenarios you cannot skip the HTTP 200 response (as suggested before) otherwise the component won't load the html contents!

    So this is what I had before in my custom renderer:

    public override void DecidePolicy(WKWebView webView, WKNavigationResponse navigationResponse, Action<WKNavigationResponsePolicy> decisionHandler)
            var url = navigationResponse?.Response?.Url;
            if (url == null) return;
            if (navigationResponse.Response is NSHttpUrlResponse)
                var resp = navigationResponse.Response as NSHttpUrlResponse;
                if (resp.StatusCode == 200) return;
            else if (navigationResponse.Response is NSUrlResponse)
                //todo handle this case too if we want to open excel files in webview

    and this is what I have changed:

    var resp = navigationResponse.Response as NSHttpUrlResponse;
    //if (resp.StatusCode == 200) return;

    Just commenting the if for StatusCode 200 and let contine with decisionHandler it works... Very very weird!

  • LandLuLandLu Member, Xamarin Team Xamurai

    Thanks for sharing your successful experience.
    Generally, the 200 StatusCode represents a successful call back from server and in that case we should use decisionHandler(WKNavigationResponsePolicy.Allow); to tell wkwebview to load this correct web request. If you do not want to show the following process in wkwebview, we can use decisionHandler(WKNavigationResponsePolicy.Cancel); to intercept it. Do not return when the code is 200, this would also block the process.

Sign In or Register to comment.