我有一个Drupal Views 2视图,它以JSON形式返回一些节点的一些字段。我可以在Chrome中查看它,它有我所期望的一切。
当我在Windows Phone 7应用程序上下载它时,一个字段,"field_images_nid"神秘地从响应中消失了。是什么导致了这一切?由于WP7的WebClient
上的一些用户代理数据,Drupal没有发送该字段吗?
WebClient data = new WebClient();
data.DownloadStringCompleted += new DownloadStringCompletedEventHandler(onComplete);
data.DownloadStringAsync(new Uri(dataUri));
所讨论的字段是指向与该节点关联的图像的链接。Views将其称为"Content: Images Full Node"。
Update:我做了一个新的测试应用程序,除了发出请求之外什么都不做,所以我可以在调试器中查看结果:
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(new Uri("http://path/to/service"));
}
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
string result = e.Result;
}
}
我创建了一个新的视图,对于给定的nid,它只返回"Title"one_answers"Content: Images (full node)"。我能够观察到Chrome和WP7请求之间同样的不一致。
更新2:当我去Chrome隐身视图url时,该字段不返回。也许是工作中的权限问题?我认为这个字段应该是匿名的
原来问题出在服务器端。当我在浏览器中测试它时,我总是在登录。使内容类型匿名可用解决了这个问题。