Xamarin Forms WebView doesn't work for my specific URL

Gordon S 501 Reputation points
2021-06-17T11:16:06.733+00:00

I have an iOS app (and Android, which works fine) where I use a WebView to load a specific URL.

It works if I use "https://google.com" but not if I use the required one which is

https://sandbox.nuapay.com/tpp-ui/redirect?userInterfacePaymentId=1234567890  

I have tried adding various settings for NSAppTransportSecurity but I can't find a clear explanation of what the options are or what they specifically do.

I tried this, but it didn't seem to help:

 <key>NSAppTransportSecurity</key>  

<dict>
<key>NSExceptionDomains</key>
<dict>
<key>nuapay.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true />
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true />
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
</dict>
</dict>

Is there a way, when debugging, to see what the problem is?

Edit:

I added a handler for WebView.Navigated and the Status is "Success", so it seems to be a problem with the content just not showing in WebView.

Edit 2;

OK, so I added the following to the WebView definition:

                         WidthRequest="500"
                         HeightRequest="1000"
                         MinimumWidthRequest="1000"
                         MinimumHeightRequest="1000"
                         HorizontalOptions="FillAndExpand"
                         VerticalOptions="FillAndExpand"

And now I can see the content ... however the WebView is now way too big, so I can only see the edge. How do I make the WebView size itself to the full space available in the App - and make the content size itself to the size of the WebView?!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,337 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. JessieZhang-MSFT 7,706 Reputation points Microsoft Vendor
    2021-06-18T06:42:32.81+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    This is App Transport Security issue , just add the following line into Info.plist and try again.

    <key>NSAppTransportSecurity</key>  
    <dict>  
        <key>NSAllowsArbitraryLoads</key>  
        <true/>  
    </dict>  
    

    Best Regards,

    Jessie Zhang

    ---
    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. PRASANT MOHANTY 1 Reputation point
    2021-06-18T12:58:33+00:00

    I will try myself and give a solution to you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.