Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Webview Post request windows phone 8.1

$
0
0

Hello friends,

I am trying to do a post request in web view, I am receiving a success response but in actual I am unable to login on webpage.

I have login page I don't want user to enter username and password so I am doing post request to login automatically. I am doing same in iOS and Android absolutely working fine on this platform but I guess Post request in web view for Windows phone 8.1 is failing here because after post request I am seeing the login page instead of Logged-in page. Here is code I am using for post request in wp8.1, The following code send request to Login page if the request is successful then session is established.

        string body = "Username=30001&Password=12345";
            string URLstring = string.Format(state.WebAppBaseUrl + state.LoginRelativePath);

            HttpRequestMessage request = new HttpRequestMessage( HttpMethod.Post, new Uri(URLstring));
            request.Content = new HttpStringContent(body);
            webview.NavigateWithHttpRequestMessage(request);

Here is response after above post request

After doing post request I am redirecting to home page

        private void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
        { 
            if (args.IsSuccess == true)
            {
                 //success
                if (IsWebViewLoaded == 0)
                {

                    state.Flow = "1";
                    IsWebViewLoaded = 1;
                 string Url = state.WebAppBaseUrl + state.WorkFlowRelativePath + "WorkflowId=" + state.WorkFlowId;
                    webview.Navigate(new Uri(Url));
                }
                else if (IsWebViewLoaded == 1)
                {


                    ProgressGrid.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                //fail
            }

        }

Viewing all articles
Browse latest Browse all 91519

Trending Articles