Windows 8.1应用程序-HttpWebRequest仅工作一次 [英] Windows 8.1 App - HttpWebRequest working only once

查看:81
本文介绍了Windows 8.1应用程序-HttpWebRequest仅工作一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的简单Windows商店应用有问题.

I've a problem with my simple windows store app.

我正在连接到SharePoint,并查询他的REST服务以获取所需的信息.实际上,我想创建一种"SharePoint浏览器",以便用户可以使用APP浏览SharePoint浏览的列表结构.

I'm connecting to SharePoint and query his REST services to get the information I need. Actually I'd like to create a sort of "SharePoint Browser" so that a user can navigate the List structure of SharePoint browsing with the APP.

实际上,我是从SharePoint获取安全令牌的,并在所有调用中都使用了它,没有任何问题.

Actually I get the security token from SharePoint and use it in all the calls without any problem.

我的电话是这样的:

var bldr = new UriBuilder(_uri.ToString());
bldr.Path += _listDataSvc + (String.IsNullOrEmpty(path) ? String.Empty : "/" + path);  
var request = HttpWebRequest.CreateHttp(bldr.Uri);
request.Method = "GET";
request.CookieContainer = _cookieContainer;
var response = await request.GetResponseAsync();

这给了我我所需要的东西.但是只有一次!如果我得到了这些数据,请向用户显示这些数据,然后用户执行再次调用同一过程的操作,系统将卡在GetResponseAsync()中,并且不会引发任何异常或其他异常.

This gives me back what I need.. But only once! If I get this data, show them to the user and the user performs an action that calls again the same procedure, the system stucks in the GetResponseAsync() and throws no exception or other.

即使我使用相同的Cookie和URL,系统的工作方式也相同...

The system works in the same way even if I use the same Cookie and URL...

可能是什么问题?我尝试使用提琴手来查找,但是所有内容都在HTTPS中,因此我可以看到该应用程序再次发送了请求,但根本没有收到任何答复.

What could be the problem? I try to find out with fiddler but everything is in HTTPS, so I can see the app is sending the request again but receives no answer at all.

推荐答案

我找出问题所在:

我在代码中的某处使用了类似的指令:

somewhere in the code I was using instructions like:

var x = request.GetResponseAsync().Result;

var x = request.GetResponseAsync().Result;

代替:

var response =等待请求.GetResponseAsync();

var response = await request.GetResponseAsync();

由于有很多调用,因此系统达到某种死锁状态,因为其他每个WebService调用都在等待上一个.

Having a lot of calls, the system reaches a sort of deadlock status because every other WebService call was waiting for the previous one.

这篇关于Windows 8.1应用程序-HttpWebRequest仅工作一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆