Pregunta ClientContext.ExecuteQueryAsync giving problems in IE

  • viernes, 16 de marzo de 2012 17:27
     
      Tiene código

    Hi

    I am using the Silverlight Client Object model to save a file into a Document Library. And I am using the ClientContext.ExecuteQueryAsync command to do the actual call. The interesting thing is while the same code is working fine in Firefox and Chrome but its giving problems in IE.

    After the file is uploaded, in the success event, I load the content of the file in an editor by directly calling the document url while in case of Chrome, this works fine, in case of IE, nothing comes...it seems like the file is missing or the content is not uploaded! It is only after I wait for some time or refresh my page multiple times, the content gets loaded in IE.

    What can be wrong? Below is the file upload code for your ref:

    var context = new ClientContext(WebPartXmlSite);
    var web = context.Web;
    var encoding = new UTF8Encoding();
    var newFile = new FileCreationInformation
    				  {
    					  Content = encoding.GetBytes(fileContent),
    					  Url = fileName,
    					  Overwrite = true
    				  };
    
    List docs = web.Lists.GetByTitle(WebPartXmlLib);
    
    File uploadFile = docs.RootFolder.Files.Add(newFile);
    uploadFile.Publish("Xml created at-" + DateTime.Now);
    
    ListItem item = uploadFile.ListItemAllFields;
    //use SPModerationStatusType
    item["_ModerationStatus"] = "0";
    item.Update();
    context.Load(uploadFile);
    
    context.ExecuteQueryAsync(successFileUpload, FailureUploadFileListner);


    Akshaya K Sharma

Todas las respuestas

  • lunes, 19 de marzo de 2012 10:24
    Moderador
     
     

    Hi Akshaya,

    Thanks for sharing your post.

    I'm trying to involve someone familar on this topic to further look at this issue.

    Thanks,
    Qiao


    Qiao Wei

    TechNet Community Support

  • miércoles, 21 de marzo de 2012 8:55
     
     

    Hi Akshaya,

    Thanks for sharing your post.

    I'm trying to involve someone familar on this topic to further look at this issue.

    Thanks,
    Qiao


    Qiao Wei

    TechNet Community Support

    Dear Qiao Wei

    Thanks for the information, is there any update regarding this issue?


    Akshaya K Sharma

  • miércoles, 23 de mayo de 2012 20:07
     
     

    Hi Akshaya,

    Greetings! Thank you for your post. We examined your query and need more inputs from you for isolation.

    a) What are results in IE if we use ClientContext.ExecuteQuery instead of ExecuteQueryAsync? The reason I ask this is that the later one would be an asynchronous call whose actual execution time cannot be predicted. So, there could be some amount of delay.

    b) Do in case of IE what do we mean when we say file is missing or content is not uploaded? Do we get some error while fetching the file from the URL or we do get the file but it is blank.

    c) How are we loading the contents of the file? Does this code fire in success callback.

    d) Also, which IE version have you tried with?

    e) Is the behaviour consistent? Have you examined the verbose ULS logs when you make a call to load the file contents. Is yes, is there any error stack you could provide us with (if any).

    --------------------------------------------

    Regards,
    Himani Sharma
    Microsoft Online Community Support

  • miércoles, 23 de mayo de 2012 20:45
    Moderador
     
     

    Hi

    Since the difference in behavious seems to occur in the success callback function, could you please post the code for that one as well ?


    Regards Bjoern
    Blog

  • jueves, 24 de mayo de 2012 12:59
     
      Tiene código

    Hi Himani

    Below are your answers:

    a) What are results in IE if we use ClientContext.ExecuteQuery instead of ExecuteQueryAsync? The reason I ask this is that the later one would be an asynchronous call whose actual execution time cannot be predicted. So, there could be some amount of delay.

    b) Do in case of IE what do we mean when we say file is missing or content is not uploaded? Do we get some error while fetching the file from the URL or we do get the file but it is blank.

    c) How are we loading the contents of the file? Does this code fire in success callback.

    d) Also, which IE version have you tried with?

    e) Is the behaviour consistent? Have you examined the verbose ULS logs when you make a call to load the file contents. Is yes, is there any error stack you could provide us with (if any).


    a) I cant use ClientContext.ExecuteQuery because it throws an exception, something related to "Invalid cross thread access, cannot block UI thread".

    b) It depends on the scenario:

         CASE 1: If a file is missing, a new file is not created. So when we try to fetch the file is not found.

         CASE 2: If a file is present, the content is not updated. So, when we try to fetch the file, the old content is returned.

         But, if I close my browser or refresh my page multiple times, then in CASE 1, the file is found and the content is also returned and in CASE 2, I get the updated content.

    c) The content loading does not file in  the Success callback. After the SuccessCallback, the user can go to our webpart and using the Sharepoint Object Model the content is fetched from the document and displayed in the webpart. This works very well in Chrome but not in IE.

    d) I tried it with IE 8 & 9. Both show the same issue. Chrome & Firebox are working fine. Quite ironic, I say.

    e) The behavior is extremely consistent! In IE it never works and in Chrome it always works! I dont know how to check the verbose ULS logs (I dont know what this means even). The issue is there's no error stack because the SuccessCallback is invoked not the failure. If you mean about some other call stack, please explain how and where I can see it?

    For Mr Bjoern,

    In the Success event, I only have one line, its something similar to this:

    public void SuccessCallback(....)
    
    {
    
    	Deployment.Current.Dispatcher.BeginInvoke(() => MessageBox.Show("File Upload"));
    
    }

    And, I dont think thats problematic ;)

    Thanks for your help!


    Akshaya K Sharma


  • viernes, 20 de julio de 2012 14:21
     
     

    Hi Akshaya,

    Given what you are seeing, it seems likely this is an issue with Internet Explorer, or possibly the settings for IIS or your SharePoint Server, rather than your code. Minimally, I would recommend making sure that you have the latest Internet Explorer updates, as well as the most recent SharePoint Server Service Pack and CU.

    Given that Silverlight is also involved here, you have a lot of moving parts. You may want to consider opening a case with Microsoft support to do detailed troubleshooting.

    If you cannot find an answer from the forum directly, please visit the link below to see the various paid support options available that may better meet your needs.

    Link:http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone


    David Wilborn MSFT