1

Currently I have a webpart on a document library which programmatically filters the view using the user's personal properties.

It works fine until I simulate multiple users (2 browsers) accessing this library. If I access on the document library with User A, it shows records only related to User A, which is correct. But now if I refresh the page with User B, instead of showing records related to User B, it is showing User A's records. If I refresh it again on User B, it will revert back to B's records.

I did some testing and found out that when I go to filter under "Library >Modify View" instead of refreshing the page, the filter is using User A's information. But when I debug the program, it is always updating the view with the correct user's information.

This is the code for the webpart

 SPContext.Current.Web.AllowUnsafeUpdates = true;
 SPList currentList = SPContext.Current.List;
 SPView view = currentList.DefaultView;
 view.Query = "<Where><Contains><FieldRef Name='" + currentList.Fields["info"].InternalName + "' /><Value Type='Text'>" + personProperties.UserProfileProperties["StaffID"] + "</Value></Contains></Where>";
 view.Update();

What is causing the problem and how can I fix this?

EDIT

I am taking a wild guess here but I think it might be because SPView's Update method is non thread safe? So when two users are concurrently accessing the list or library, one will override another's update query. But I have yet to find a way to solve this.

0

I'm suspecting that since you're using SharePoint context, it is being populated by one user's data and because the webpart has admin privilages it does not check which user was the context created under.

You can try from two different machines. If it is the same, the context is the one to blame. Opening site\web rather with context URL should solve the problem.

  • Unfortunuately, changing from context URL to OpenWeb did not fix the problem. – user59385 Aug 25 '16 at 3:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.