I've already tried to search the web but I always get to some point from which I don't know how to get further.

I have a Visual web part which needs to load data from external sources (different domain). The sources are .aspx pages returning json and I need to load these data asynchronously.

1) I've tried to use the code below, but it throws an exception:

Page.RegisterAsyncTask(new PageAsyncTask(LoadData));

This operation requires the page to be asynchronous (the Async attribute must be set to true). at System.Web.UI.Page.RegisterAsyncTask(PageAsyncTask task)

and I'm not able to figure out how to set this attribute of the Page directive from the webpart. Moreover in some articles and blogs I found was written that SP doesn't support it, so I left this idea. But is it possible or not? If yes, how do I set it up?

2) I tried to use jQuery ajax, but it fails and returns no error. I think that the problem can be caused by a "cross domain" call. I've found there is SPRequestExecutor, but I'm not able to find some useful info on how to use it.

What is the best approach (with some examples please)?
I bet that many SP developers need it, so there must be something.
I prefer the js solution if you could direct me to some relevant information.

  • Do you have server access to the other domain? If so, can you set CORS headers? What type of data are you trying to get? – azium Sep 17 '15 at 23:26
  • as I wrote, it's json returned. I can ask the developer of the server side to add CORS, but I'd also like to know how it is with using the PageAsyncTask in Sharepoint. In book Inside Microsoft Sharepoint 2013 it's mentioned (p.347), but there is not mentioned (and I've not beenable to find it even elsewhere) how to modify the Page directive of the hosting page. And for ex. here [link]goo.gl/BVqlhm is mentioned that SharePoint's page directive does not accept attribute Async="true", SharePoint’s SPPageParserFilter class blocks some page directive attributes. It confuses me. – Filip M. Sep 18 '15 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.