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 8963287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:19:26+00:00 2026-06-15T16:19:26+00:00

I have been struggling with this for a while now and I cannot find

  • 0

I have been struggling with this for a while now and I cannot find any helpful information on the interweb or forums etc.

Basically I have been asked to output the contents of my SharePoint 2010 document library onto a standard MVC web page.

Here is my code:

public class HomeController : Controller
{
  public ActionResult Index()
  {
    using (ClientContext site = new ClientContext("Http://MySPSite"))
    {
      List list = site.Web.Lists.GetByTitle("MyList");    
      site.Load(list);
      site.ExecuteQuery();
    }

    return View();
}
  • 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-06-15T16:19:27+00:00Added an answer on June 15, 2026 at 4:19 pm

    I managed to pull listitems that I wanted to using the following

    public ActionResult Index()
            {
                ViewData["Message"] = "Welcome to ASP.NET MVC!";
                List<string> documentTitles = new List<string>();
                using (ClientContext context = new ClientContext("http://siteurl"))
                {
                    List list = context.Web.Lists.GetByTitle("doctest");
                    context.Load(list);
                    CamlQuery query = new CamlQuery();
                    query.ViewXml = "<View/>";
                    ListItemCollection listItems  = list.GetItems(query);
                    context.Load(list);
                    context.Load(listItems);
                    //context.Load(listItems ,items => items.Include(
                    //    item=>item["FileLeafRef"] 
                    //    ));
                    context.ExecuteQuery();
                    foreach (ListItem item in listItems )
                    {                    
                        documentTitles.Add(item["FileLeafRef"].ToString());
                    }
                }
                return View(documentTitles);
            }
    

    FileLeafRef is the internal name for the “Name” column.

    I commented out the include FileLeafRef since it is included by default but you may need it for other columns.

    Also this needs to be done in .NET 3.5 since you are using the client libraries.

    You will need to populate an object with the data you want and pass that to the view (If you are not aware of this you should look at some mvc examples. From your example I can’t tell if you know mvc or not or if you are just posting code to demonstrate the SharePoint issue)

    You may also have to set the context crentials

    context.Credentials = new NetworkCredentials("Username", "Password", "Domain");
    

    before calling execute.

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

Sidebar

Related Questions

I have been struggling with this problem for a while now, so any help
I have been struggling with this for a while now. given a set of
I've been struggling with this issue for a while now. I have OpenCart 1.5.2.1
I've been struggling with this for a while. Basically, I want to have two
I have been struggling with this a while now. I implemented a basic IHttpHandler
I have been struggling with this for a while now. I have a Master
Iv been struggling with this for a while now an I have exhausted all
I have been struggling with this for a while now, somehow JQuery is escaping
Hi all i have been struggling this for a while now! I have some
I have been struggling with this problem for a while now. I have a

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.