我是Windows Phone 7& S的新手。 C#。我正面临导航到新屏幕的问题。我的要求是我需要检查登录凭证到服务器&如果确定,则转到下一个屏幕。但我收到错误“UnauthorizedAccessException” - “无效的跨线程访问”。 。
查找以下代码
private void button1_Click(object sender, RoutedEventArgs e)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(uri));
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.BeginGetResponse(ResponseCallback, request);
}
private void ResponseCallback(IAsyncResult asynchronousResult)
{
var request = (HttpWebRequest)asynchronousResult.AsyncState;
var response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
if (response.StatusCode == HttpStatusCode.OK)
{
this.NavigationService.Navigate(new Uri("/tabview.xaml", UriKind.Relative));
}
}