Thursday, 15 April 2010

windows runtime - WinRT 8.1 WebView Content Type -


I am trying to load the webwall by using HttpRequestMessage in the Windows Phone 8.1. The problem is that the content is checked in the Fiddler when the header in the header is unavailable in the content headers.

  byte [] postData = GetWebviewPostDataBytes (); HttpRequestMessage Request = New HttpRequestMessage (HttpMethod.Post, URI Ready); Var httpContent = new HttpBufferContent (postData.AsBuffer ()); HttpContent.Headers.Add ("Content Type", GetContentType ()); Request.Headers.Add ("User-agent", GetUserAgent ()); Request.Content = httpContent; WebView.NavigateWithHttpRequestMessage (requested);  

I have found some links where it has come up as an internal bug. Can anyone tell me an alternate solution on this?

The only solution I have found is that you can use a form to load your page. Are there.

I am loading a local HTML page which I am generating with my POST parameters.

This page contains a hidden HTML form that will be submitted once I load the page.

Then the web page is loading:

  1. A local HTML page is a form
  2. Load this page in your web view
  3. Once the page has loaded, request to submit a form using the webpage postcontent () function
  4. The webview will then navigate to the expected webpage with a content-type header set

This sample code is in WinJS, but it can be easily transmitted to C # Land because it is the same webview component.

  var htmlcontent = "  gt; script type = 'text / javascript' & gt; function postcontent () {document.getElementById ('PostForm'). & Lt; / head>  
& lt; / body & gt; & lt; / html & gt; "; Var inputFields = ""; Var easter = payload content. first (); Whereas (iterator.hasCurrent) {inputFields + = "&"; hidden on input = '' name = '{n}' value = '{v}' / & gt; ("{N}", "iterator.current" key) .replace ("{v}", iterator.current.value); Iterator.moveNext (); } Var htmlContent = htmlContent.replace ("{targetUrl}", "Your URL is right here"). ("{InputFields}", input fields); This._webviewElement.navigateToString (htmlContent);

In the page loaded event, you will need to request a webview to perform a 'postcontent ()' javascript function to submit the form.

  this ._webviewElement.invokeScriptAsync ("postContent");  

Hope it helps.


No comments:

Post a Comment