1
Code accessing document library forces login (SP 2010)
Post Body
I have code that's pulling some images from a document library. When I'm logged in and testing everything works just fine but when it's published it forces a log in screen.
Here's the kicker: if I reference the images through normal HTML, the published page doesn't require a login. It's only when I try to pull the images in and build a list of them into an asp:literal control.
The permissions on the list allow anonymous read, as far as I can tell. Something is fishy somewhere. Please help!
Below is the code I'm using:
public void GetBanners() {
string strCode = "";
using (SPSite oSite = SPContext.Current.Site) {
SPList oList = oSite.AllWebs[0].Lists["MainPage Banner Library"];
SPView lv = oList.Views["All Pictures"];
SPListItemCollection lic = oList.GetItems(lv);
foreach (SPListItem li in lic) {
if(li["Enabled"] is bool && (bool)li["Enabled"] == true) {
if(li["URL"] is string && li["URL"].ToString() != "") {
strCode = strCode "<a href=\"" GetURL(li["URL"].ToString()) "\" target=\"_blank\"><img src=\"/MainPage Banner Library/" li["Name"].ToString() "\" alt=\" \" /></a>";
} else {
strCode = strCode "<img src=\"/MainPage Banner Library/" li["Name"].ToString() "\" alt=\" \" />";
}
}
}
}
ltBanners.Text = strCode;
}
Author
Account Strength
100%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
19,503
Link Karma
7,647
Comment Karma
11,734
Profile updated: 2 days ago
Posts updated: 7 months ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 12 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/sharepoint/...