2

after a bakup/ restore of SPWEB, if I try to Get a SPLIST by Server object Model code, it returns me

 public bool OnNotification(SPAlertHandlerParams ahp)
 {
  SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(ahp.siteUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {

                        SPList lookupList = web.Lists[new Guid(ahp.a.ListID.ToString())];
                        //list = web.Lists[ahp.a.ListID];
                    }
                }
            });

enter image description here

List does not exist. The page you selected contains a list that does not exist. It may have been deleted by another user.

If I try to get the same list using COM, the result is success:

 string siteUrl = "http://mysite/";
            SP.ClientContext clientContext = new SP.ClientContext(siteUrl);
            clientContext.Credentials = new NetworkCredential("user", "pass", "domain");
            SP.List oList = clientContext.Web.Lists.GetByTitle("mylist");

            clientContext.Load(oList);
            clientContext.ExecuteQuery();
0

Can you try using below?

var list = web.TryGetList("Title");

I think the problem with your SSOM code is quite obvious. Let me know if snippet above works.

|improve this answer|||||
  • Hi Thanks for the answer. I added the full snippet above. The object is an Alert. And it's got some List information about the List the alert come from but not the ListName. The problems is that, how you can see above, When I try to get the the list from the site, the code can't find it. – hello B Feb 12 '16 at 19:07

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.