我是 Windows Phone 7 和 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));
}
}