I'm developing a Windows phone 8.1 app and there's this scenario where I should open the webview for the user to enter the card details. Once the card details are entered and processed, the payment API will send the transaction details back as a POST request to the webview. I'm not able to get the POST data, tried so many methods.
How do I get the post data returned back from the server? Thanks in Advance
Answer for UWP.
Important Note: I have html document locally in localcache folder. I open it in webview using
ms-appdata://
scheme.Story of infinite troubles (may be it some you some time):
If I sent the POST request, I got nothing. I get
WebView_NavigationStarting
event, but the Uri only was transferred. No POST data.I try to debug using
alert
. Just to realize thatalert
doesn't work inWebView
.I found the fix that makes
alert
works usingScriptNotify
events. Just to realize thatScriptNotify
doesn't work withms-appdata://
scheme. So the fix didn't work as well.I learned how debug in VS by going to Project settings / Debug / Debugger type / Application process and select "Script". Then I realized that I can't put breakpoints in script in Visual Studio. And then I found a little hack -- put the word "debugger;" in your javascript code and VS will stop there. And you can debug using F10/F11. Oh, yeah, baby!
Then I finally gave up and changed it to GET request. Just to realize that it only works until form data exceed ~2K. After that nothing.
NavigationStarting
never fired, just nothing happens.Finally, here the solution:
Not really elegant, but it works!!! And I was able to transfer 20K+ this way. This is exactly what I needed.
If you have access to webpage code then you can use WebBrowser.ScriptNotify for transfering data from webpage to WP
Found a way to do this, actually the Server POST request had all the arguments in the Querystring itself
Handled the Navigation_Completed event of the webview, the args URI will have all the details required