Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display HTML in WebView in Windows 8 Metro app?
    text
    copied!<p>I'm building an app for Win8 (Metro) and for WP8. In this app I have a WebView in which I need to load some webpage. I'm getting HTML via post request in WP8 like this:</p> <pre><code>void LoadView(string username, string password) { string postDataStr = String.Format("username={0}&amp;password={1}", username, password); byte[] postDataByte = Encoding.UTF8.GetBytes(postDataStr); string additionalHeaders = "Content-Type: application/x-www-form-urlencoded" + Environment.NewLine; var urlLogin = new Uri(new Uri(APIConf.API_SERVICE_ENDPOINT), APIConf.LOGIN_URL); myWebView.Navigate(urlLogin, postDataByte, additionalHeaders); } </code></pre> <p>That works just fine, but I am having problems with Win8 Metro app. I have tried like this:</p> <pre><code> async Task&lt;string&gt; GetWebContent(string username, string password) { string serviceMethod = APIConf.LOGIN_URL; HttpClient client = new HttpClient(); client.BaseAddress = new Uri(APIConf.API_SERVICE_ENDPOINT); HttpContent content = new FormUrlEncodedContent(new[] { new KeyValuePair&lt;string, string&gt;("username", username), new KeyValuePair&lt;string, string&gt;("password", password) }); HttpResponseMessage response = await client.PostAsync(serviceMethod, content); Stream responseStream = await response.Content.ReadAsStreamAsync(); String sResponse = null; using (StreamReader responseReader = new StreamReader(responseStream)) { sResponse = responseReader.ReadToEnd(); } return sResponse; } async void LoadViewInWin8(string username, string password) { var htmlContent = await API.APIController.GetWebContent(username, password); if (!String.IsNullOrEmpty(htmlContent)) { myWebView.NavigateToString(htmlContent); } } </code></pre> <p>When I execute this code, myWebView load and show HTML that I got, but it doesn't load any of the styles from web. Also, when I click on some of the links in shown html, I get page "Navigation to the webpage was canceled". I know that Win8 WebView has some problem with Navigate() methoid but is there a way that I can load this webPage in my WebView properly? I really would appreciate any help that I can get with this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload