Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6729273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:16:11+00:00 2026-05-26T10:16:11+00:00

I have a simple custom web part with three drop downs that reads from

  • 0

I have a simple custom web part with three drop downs that reads from three different list. When the user tries to access this page they get prompted for password, if they don’t enter any credentials they get a 401 error.

I have enabled anonymous access both in central admin and on the site itself, users can browse to the site and view it without getting prompted for password. I have made sure that anonymous user have “view” access to the lists in questions but they still can’t view any page with a custom web part.

So is it a SharePoint setting or do I have to add something in my web part projects?

Thanks in advance.

Edit:

I call this method in page load and still get the same error

private void LoadImageGallery()
{
    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
    SPSite oSiteCollection = SPContext.Current.Site;
    SPWebCollection collWebsites = oSiteCollection.AllWebs;
        DataTable dt = new DataTable();
        for (int i = 0; i < collWebsites.Count; i++)
        {
            using (SPWeb oWebsite = collWebsites[i])
            {
                if (oWebsite.Title == "People")
                {
                    SPList peopleList = oWebsite.Lists["Pages"];
                    if (peopleList != null)
                    {
                        SPListItemCollection collListItems = peopleList.Items;
                        dt = collListItems.GetDataTable();
                        // Include Surname to omit default/search page
                        dt = collListItems.GetDataTable();
                        rptImageGallery.DataSource = dt;
                        rptImageGallery.DataBind();
                    }
                }
            }
        }
    });
}

I also tried with

SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSiteCollection.AllWebs;

above runwithelevated..

I set system\sharepoint to have full control in the entire site

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:16:12+00:00Added an answer on May 26, 2026 at 10:16 am

    For anonymous access, you have to modified your code for access List to bind drop down list as below. Add you code in SPSecurity.RunWithElevatedPrivileges Delegate method.

           SPSecurity.RunWithElevatedPrivileges(delegate() {
              using (SPSite site = new SPSite(web.Site.ID))
              {            
                 //ADD YOUR WEB PART Code HERE     
              }
           });
    

    Important: You must create SharePoint Objects in this Delegate otherwise code will not run with Admin access.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple web part with a custom enum property (which SharePoint renders
I have a created a simple Custom ServiceHost that inherits from ServiceHost and overrides
I have a simple custom view that is connected via outlet to a NIB.
i'm missing something fundamental here. i have a very simple custom class that draws
I have a simple C++ DLL that implements a few custom actions for a
Suppose I have a simple XHTML document that uses a custom namespace for attributes:
I have a simple create user wizard and custom membership provider which was taken
I am creating a very simple web part that accepts entry on a form
I created a simple custom control that only inherits from the Literal control, and
I have built a custom web part using Visual Studio. Is it possible to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.