使用Silverlight Windows Phone 8.1项目
我正在尝试从网站加载数据.不过,我必须首先在该网站进行身份验证.所以我在网站上发帖子,使用这里的CookieAwareWebClient的轻微修改版本.
class CookieAwareWebClient : WebClient
{
public CookieContainer Cookies = new CookieContainer();
protected override WebRequest GetWebRequest(Uri address)
{
var request = base.GetWebRequest(address);
if (request is HttpWebRequest)
(request as HttpWebRequest).CookieContainer = Cookies;
return request;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我做的WebClient发送POST与Username和Password继续让我的网站async和我的处理现场数据DownloadStringCompleted-EventHandler.到现在为止还挺好.现在我想扩展它并获得多个网站.
我不必一次性完成所有这些,事实上,让它们一个接一个地更好.
但我不知道该怎么做.
我的代码到目前为止:
using System;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Windows.Web.Http;
using Microsoft.Phone.Shell;
using StackOverflowApp.Resources;
namespace StackOverflowApp
{ …Run Code Online (Sandbox Code Playgroud) 我有一堂课叫做Document
public class Document : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
private string oldId;
public string OldId
{
get { return oldId; }
set { id = value; }
}
private string id;
public string Id
{
get { return id; }
set {
id = value;
NotifyPropertyChanged("HasChanged");
}
}
private string path;
public string Path
{
get { return path; }
set { path = …Run Code Online (Sandbox Code Playgroud)