locked
WebView.Refresh() does not refresh the web page RRS feed

  • Question

  • Hi,

    I'm using WebView to show the online help of my app. All is perfect, except the Refresh() method. When I change a page of my online help, the Refresh method does not what it shall do. When I do the same in Edge, the changed web page is displayed as expected.


    PaulBiz


    PS: After logoff/login the page is updated.
    • Edited by PaulBiz Tuesday, July 17, 2018 10:45 AM PS
    Tuesday, July 17, 2018 8:57 AM

Answers

  • Hi,

    Sorry for the delay.

    After researching, the problem seems to be related to the cache of the webview. So the solution I found is that you might need to clean your cache before refresh. 

    Like this:

      private async void RefreshButton_Click(object sender, RoutedEventArgs args)
            {
    
                await Windows.UI.Xaml.Controls.WebView.ClearTemporaryWebDataAsync();
                _contentWebView.Refresh();
            }

    In my test, it works well when refresh the page. The content in iframe tag could be updated.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 13, 2018 7:09 AM

All replies

  • Hi,

    What kind of project is it? Is it a UWP JS project? 

    How about create a blank project and use this method in a simple page? Will it work?

    If it is a UWP project, could you please share me the code snippet that how you used it?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 18, 2018 1:38 AM
  • Hi Roy,
    thank you for your answer. My project is a UWP project. It only shows the web pages. It does not generate or update the pages.

    I have created a small test project to verify the problem with my online help. The result is:

    The Refresh() method refreshes static web pages as expected. But my online help pages are generated with a tool. This tool creates the pages within i-frames and that seams be the reason for not refreshing the page content. The page bodies are as shown below:

    <body class="i-layout-container" id="i-top-frame-container">
        <div id="i-busy">&nbsp;</div>
        <iframe class="ui-layout-center" id="i-content" name="i-content" frameBorder="0"></iframe>
        <iframe class="ui-layout-west" src="webnav.html" id="i-nav" name="i-nav" frameBorder="0" style="padding: 0"></iframe>
        <script type="text/javascript">setIsResponsiveEnabled = true;</script>
        <script type="text/javascript">
            $(function() {
                var documentInstance = new Innovasys.Content.Document(document);
                documentInstance.getFeatureByName("TopFrame").setForcedDisplayMode(null);
                documentInstance.getFeatureByName("TopFrame").defaultTopic = defaultTopic;
                documentInstance.isContentDocument = false;
                documentInstance.isResponsiveEnabled = !(typeof setIsResponsiveEnabled === "undefined");
                documentInstance.load();
            });
        </script>
    </body>

    You can find the test project here. But it contains only a test for a local generated html file ($"ms-appdata:///temp/Test/{file.Name}". For a real web test you must have an external  static web page which you can change and for an i-frame test it must contain i-frames. The test project allows only to specify the page address not to generate nor to change an external page.

    Best regards,
    Paul


    PaulBiz

    Saturday, July 21, 2018 2:09 PM
  • Hi,

    Sorry for the delay. I'm still investigating this. 

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 30, 2018 6:32 AM
  • Hi,

    Sorry for the delay.

    After researching, the problem seems to be related to the cache of the webview. So the solution I found is that you might need to clean your cache before refresh. 

    Like this:

      private async void RefreshButton_Click(object sender, RoutedEventArgs args)
            {
    
                await Windows.UI.Xaml.Controls.WebView.ClearTemporaryWebDataAsync();
                _contentWebView.Refresh();
            }

    In my test, it works well when refresh the page. The content in iframe tag could be updated.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 13, 2018 7:09 AM
  • Hi Roy,

    thank you very much for the solution.

    Best regards,
    Paul


    PaulBiz

    Monday, August 13, 2018 7:47 AM