locked
inspect and copy headers before Webview navigates RRS feed

  • Question

  • I need to modify request headers before the WebView navigates. I do this on NavigationStarting:

                        Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, args.Uri);
                        // Do Stuff
                        WebViewMain.NavigateWithHttpRequestMessage(httpRequestMessage);
    

    But of course because I create a new RequestMessage, the original data is all lost.  How can I get a handle to the existing requestMessage and modify that one instead?


    Dexter

    Friday, October 25, 2013 2:01 PM

Answers

  • Hi Dexter,

    Sorry for the late response.

    Basically the webview NavigationStarting event comes up with a WebViewNavigationStartingEventArgs, which only consists Cancel and Uri. I don't think you could get other original data from this.

    I think currently you create the requestMessage by getting the form from Yahoo page and insert the data to your own request Message, the reason for Google stuff might be Google authorization contains more data(basically the OAuth stuff). WebAuthenticationBroker class will help with Google logon.

    Best Regards,

    --James

     


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Monday, October 28, 2013 9:11 AM
    Moderator

All replies

  • One thing I noticed is that sometimes the post goes through fine and other times it does not.

    For example, if I use the WebView to logon to Yahoo via this method, it works fine.

    If I use it to logon to Google, it does not.

    Is Google perhaps requesting a different method other than post?


    Dexter

    Friday, October 25, 2013 3:28 PM
  • Hi Dexter,

    Sorry for the late response.

    Basically the webview NavigationStarting event comes up with a WebViewNavigationStartingEventArgs, which only consists Cancel and Uri. I don't think you could get other original data from this.

    I think currently you create the requestMessage by getting the form from Yahoo page and insert the data to your own request Message, the reason for Google stuff might be Google authorization contains more data(basically the OAuth stuff). WebAuthenticationBroker class will help with Google logon.

    Best Regards,

    --James

     


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Monday, October 28, 2013 9:11 AM
    Moderator