.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Access SharePoint COM from ASP.NET Web Application

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :SharePoint


I have a big issue in accessing a SharePoint site from ASP.NET Web Application.

Console code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace ConsoleApplication1
  class Program
    static void Main(string[] args)
      using (SPSite site = new SPSite("http://server/site"))
        using (SPWeb web = site.OpenWeb())

          foreach (SPList myList in web.Lists)


This code is a console app that will display all the lists from that site. Works fine, no problem!

System Info: Windows Server 2008 R2, SharePoint Server 2010, SQL Server 2008 R2. My user has admin rights everywere.

Now I created a new ASP.NET Web Application project, .NET Framework 3.5, AnyCPU (and I use Visual Studio Development Server, not deployed yet)

On the default.aspx page I added: one ListBox and a Button.

Event handler for Button Click code is the same as the code above, a simple thing to display all lists from a site.

Result: is not working!

Are there issues in developing ASP.NET Web Application that uses SharePoint Client Object Model?

I just want to

View Complete Post

More Related Resource Links

Is SharePoint and Access 2010 the right platform for subscription based web application?



I posted a similar question in the Access Form and the MVP's there suggested I post a follow up here, to clarify the SharePoint issue. 

My Question: is SharePoint and Access 2010 a good platform, or can it do what I need?

The Scenario:

I currently have a client/server app built in Access 2002 with many clients in a single industry. My clients are very mobile and would like to be able to do their work in the app anywhere, not just while connected to the office network. Likewise, a large percentage in that industry have Macs (I've used Windows in Parallels or Fusion for these clients but it's not a smooth process, in a lot of 'connectivity' ways). My clients are asking, and my competition already has, web based applications. I very much need to get my app on the web. Along with that, I need to set it up as a monthly subscription based application.


So I'm hoping Access and SharePoint can do this. I don't know ASP or PHP or SQL so it'd be a steep learning curve if I have to go that route. I don't know much about SharePoint but have watched videos about using it for Access Web databases as well as RichClient/SharePoint Lists. 

It's possible I could have over 1000 clients, each of which will have a few thousand records in the main few tables (SP Lists). Each client could also have several users l

Can not access SharePoint Lists from ASP.NET web application



I don't know if this is the right place for this but is related to SharePoint.

using (SPSite site = new SPSite("http://server/siteName/"))
       if (site != null)
         using (SPWeb web = site.OpenWeb())
           foreach (SPList myList in web.Lists)


Example this code above:

I connected remotelly on the server, and in VS 2010 created a new ASP.NET Web Site. Added a new .aspx page and in code behind in the Page_Load event handler i put the code above. (lbLists is a ListBox on the .aspx page).

When i run this page and try to see the results in browser it doesen't work!!

The same code works perfectly on a windows form application!! What is the reason why it is not working?

It ment to not work? How can i make a web application (ASP.NET) that i can access a SharePoint site programmatically and display the items?

Then i want to deploy this app and run it in browser.


Access denied when Searc Service Application tries to crawl Sharepoint content


I have just set up a new SP2010 environtment(3 servers: WFE, App, SQL).

When I try to get my Search Service Application to crawl my main SP site and my MySite location, I get the following error in the crawl log:

"Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled."

Things I have checked:
I have ensured that the default access account has "Full Read" on the web application
-I set up crawl rules for both sources specifying a service account that has admin access to the content on those sites
-I logged in to the SP sites using the service account that the Service Application is using to crawl
-I even created a brand new search service application from scratch and got the exact same results

The only difference between this environment and my test environment, where search works just fine, is that this is the production environment and so it uses FQDN with a host header: http://portal.company.org.


attach access database in SharePoint 2010 service application


I am planing to publish Access database MyDB into Access Service application in SharePoint 2010 server farm. MyDB has following tables,

tblShared1, tblShared2, tblShared3, tblShared4, ... 

Is that possible for each user to open an Access database locally and set linked tables above in MyDB Access database? If yes, how it works?

Thanks in advance,    

Integrating a Legacy Web Application in SharePoint

This month we will continue with the theme of deploying Microsoft's SharePoint as a company intranet by describing a method for integrating a legacy Web application inside a SharePoint site.

In many companies the intranet site is not just a home page with announcements. It houses Web applications used by many different departments. In last month's article, I built a page to search the employee table in Northwind (the sample database included in Microsoft's SQL Server). This month, I will move the Web pages used to add/remove records from the table into the SharePoint intranet.

MVC architecture in ASP.Net using C# and Microsoft Data Access Application block

The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:

Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).

View. The view manages the display of information.

Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.

SharePoint Application and Site Pages - Part 1 of 2

In this first part of the two part series, Steven covers the differences between Site and Application pages in SharePoint 2007, why each may be used in various circumstances, and prepares for the construction of a menu located application page. After a brief introduction he examines the concept of Site Pages and Application Pages separately in detail with supported screenshots.

SharePoint Application and Site Pages - Part 2 of 2

As the second article in a two part series, Steven examines the attributes and details of a SharePoint 2007 application page, including the construction and feature deployment of the same page based project. Since this is a WSS level objective, as opposed to MOSS, you will not need MOSS to work with the code included in this project. Windows Server 2003, WSS, and Visual Studio 2005 are all that is needed, with no additional add-ons. He provides a detailed analysis of each step involved in the creation and deployment of the project.

Application Vs. Content Pages in SharePoint

SharePoint has two types of ASPX pages. One type is the application page, also known as a _layout page. The other type of ASPX page is a content page, also known as a site page. Each of these page types is stored in a different location in SharePoint. When developers create custom ASPX pages, they must decide on the page type.

Integrating a Legacy Web Application in SharePoint

This month we will continue with the theme of deploying Microsoft's SharePoint as a company intranet by describing a method for integrating a legacy Web application inside a SharePoint site.

Using SharePoint Search feature in ASP.Net Application

Integrating ASP.Net application in to MOSS 2007 to utilize SharePoint Enterprise Search Feature can be done by using Business Data Search.

Microsoft Application Block for Data Access in .NET


Hi all,

I was rummaging the internet learning aspx and came across the concept of: Microsoft Application Block for Data Access in .NET

It seems great of course. The articles are all early 2003-5 such as


So the question is - is this tech still relevant and should I be using it?



Data Access: Building a Desktop To-Do Application with NHibernate


Building an NHibernate-based desktop application isn't any harder than building a web application, and in many cases NHibernate simplifies elements of session handling and concurrency.

Oren Eini

MSDN Magazine December 2009

Data Points: The Enterprise Library Data Access Application Block, Part 3


E nterprise applications can have a wide variety of data update requirements. Sometimes you need to save multiple rows of changes at once within a single transaction. Other times, the user must be allowed to enter multiple rows of data, send them to the database in a batch; and if a row or two fails, only the rows that succeeded should be committed and remain committed.

John Papa

MSDN Magazine October 2005

Data Points: The Enterprise Library Data Access Application Block, Part 2


Last month I explored the foundation of the Enterprise Library Data Access Application Block (DAAB) including how it all fits into an architecture (see Data Points: The Enterprise Library Data Access Application Block, Part 1).

John Papa

MSDN Magazine August 2005

Data Points: The Enterprise Library Data Access Application Block, Part 1


A solid data access later (DAL) can benefit an application by hiding redundant tasks, helping handle exceptions more gracefully, helping clean up resources more efficiently, and providing a layer of abstraction from the database.

John Papa

MSDN Magazine July 2005

SharePoint Portal Server 2001: Search and Access Disparate Data Repositories in Your Enterprise


The knowledge worker is greatly empowered if she is able to access information across the enterprise from a central access point. With the SharePoint Portal Server 2001 Search Service you can catalogue information stored in Exchange public folders, on the Web, in the file system, and even in Lotus Notes databases. This article discusses the use of ActiveX Data Objects and the Web-based Distributed Authoring and Versioning protocol for creating search solutions based on SharePoint Portal Server 2001.

Kayode Dada

MSDN Magazine April 2002

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend