'Item Does Not Exist' error reading ShareP

2019-05-14 23:11发布

问题:

I have a list in SharePoint 2010. If I add items to the list programmatically (via a custom webpart), I can later read those items and show them in other web parts. However, if I attempt to read a list item added through the web interface, I get the following error in my webpart:

Item does not exist. The page you selected contains an item that does not exist. It may have been deleted by another user.0x81020016

The weird part is, in the debugger, I see that the list item is properly read. I'm pulling what's left of my hair out over this one.

Any ideas?


Here's the answer for anyone who cares:

I was calling my page like this - mywebpage.aspx?id=1, where id=1 was the id of the item in the list I wanted my webpart to display. For some reason known only to Microsoft, using 'id' in the query string is a no-no. So I changed the param name to 'lid' and now everything works like I would expect.

Thanks for everyone's responses.

回答1:

You are most likely accessing the SPItem with incorrect credentials inside your web app. You should provide proper user impersonation.

Please read my post how to configure web app for impersonation for more details:

WindowsIdentity and Classic .Net App Pool



回答2:

Well, I think I've found it. I was calling my page like this - mywebpage.aspx?id=1, where id=1 was the id of the item in the list I wanted my webpart to display. For some reason known only to Microsoft, using 'id' in the query string is a no-no. So I changed the param name to 'lid' and now everything works like I would expect.

Thanks for everyone's responses.



回答3:

You, as the creator of an item, will have permission to access it. You need to check the permissions on the SharePoint list you are querying to see what permissions the account your code it using to authenticate has on the list for which you are not the author.