Windows 8.1 App - HttpWebRequest working only once

扶醉桌前 提交于 2019-12-25 12:20:30

问题


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

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.

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

My call is something like:

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();

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.

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

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.


回答1:


I find out where the problem was:

somewhere in the code I was using instructions like:

var x = request.GetResponseAsync().Result;

instead of:

var response = await request.GetResponseAsync();

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



来源:https://stackoverflow.com/questions/22806771/windows-8-1-app-httpwebrequest-working-only-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!