I am new to SharePoint development, I am building an internet facing website with anonymous permissions for the pages, my current situation is that my lists are accessible without any security upon them and when I tried adjusting the permission on the lists and libraries to have certain permissions my code couldn't read or write from the lists.
Can anyone help me achieve a point where the pages are accessible without SharePoint security while the lists and libraries aren't?
Here is an example of how I read from the lists
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite newSite = new SPSite(SPControl.GetContextSite(Context).Url))
{
using (SPWeb web = newSite.RootWeb)
{
configurationslist = web.Lists[configurationListName];
q.Query = "<Where>";
q.Query += "<Eq>";
q.Query += "<FieldRef Name='LinkTitle' />";
q.Query += "<Value Type='Text'>" + key + "</Value>";
q.Query += "</Eq>";
q.Query += "</Where>";
try
{
SPListItemCollection listCollection = configurationslist.GetItems(q);
if (listCollection.Count > 0)
{
foreach (SPListItem item in listCollection)
{
returnedValue = getStringValue(item["Value"]);
result = true;
}
}
else
{
returnedValue = "";
result = false;
}
}
catch (Exception e)
{
returnedValue = "";
result = false;
}
}
}
});