7

We are looking into developing a site that uses MVC3 as the front-end and SharePoint 2010 as the data layer. We would like to keep SharePoint as out of the box as possible and display the data in MVC3. The administration of the site will handled in SharePoint but the end user will be logging into the MVC3 site.

Is there any best practices in using SharePoint in this manner? I was considering hosting the MVC3 site under the SharePoint IIS site so that it can take advantage of the SPContext but this might not workout since MVC3 is a .net 4.0 app. We will be hosting the site from the same server as the SharePoint site. Can we use the server object model to talk to SharePoint? If we use the server object model, how can we go about using the current users security context to access SharePoint (the MVC3 site will be a winauth application).

5 Answers 5

2

I understand your situation. We are asking ourself the same questions.

You can't use the advantage of SPContext. You can't even use the server object model because your application is in .net 4.0. For exemple, creating a new SPSite won't work.

Only solutions :

  • Call SharePoint WebServices from your ASP.NET MVC app
  • Create WebServices hosted in SharePoint. (and call them from your app)
  • Try doing something complex like that

I think you can pass the user security only if you use Kerberos. If you use NTLM you will fall in the double-hop issue

4
  • Thanks, that was helpful. I had the same thing in mind - using the client object model to communicate with SharePoint.
    – Emon
    Jun 22, 2011 at 3:59
  • OR Instead of using MVC3 go with MVC2 and you can integrate MVC into your Sharepoint 2010. That's what I've done. Oct 4, 2011 at 6:07
  • @RobertKoritnik : how do you integrate MVC in SharePoint ? Using this ? sharepointmvc.codeplex.com Oct 4, 2011 at 20:08
  • 3
    Actually not... I've checked multiple of possibilities outlined on the web and none delivered what I needed so I had to write my own code. I'm still planning to put the code on my blog but I can't find the time because there're many things to consider. Anyway. If my Site is located on www.someserver.com, then my MVC application is running under www.someserver.com/someMVCfolderName this way everything else inside the site is still available and doesn't interfere with existing stuff. My app runs under SPContext and uses SP authentication etc. Oct 4, 2011 at 20:21
1

Why would you use SharePoint as data layer if it is not being used as UI also? It is not an efficient database replacement as you have no control over how it keeps the data. I do not think it is a good practice to do the way you are planning to do.

2
  • We would like to make this site html5 compatible and we need to make many custom UI elements. The reason for using SharePoint as the back-end is to take advantage of the document management, workflow and security capabilities.
    – Emon
    Jun 22, 2011 at 1:54
  • 1
    @SandeepSingh: Data administration maybe? Front-end usually does just a few data displays while administration can be more extensive. Using Sharepoint for that is very reasonable. Oct 4, 2011 at 6:08
1

We just released an opensource project that does exactly what you ask: it allows you to use SharePoint on the backend and MVC3 on the frontend. We've been using the approach in production for the last two years and wanted to share the code with the community since we're aware that others will find it useful as well.

Documentation is still sparse - please feel free to reach out if you have any questions.

http://www.slamcms.com

Yours,

Allan

0

I am planning to use Client Object Model for my project too. We are trying to avoid Master Page customization and building custom web parts. However I was told to look into Server Object Model as the site(Intranet) will be hosted on the same server as Sharepoint and avoid Web Services due to performance issues.

Can someone please advise the advantage of one approach over another?

1
  • 1
    This probably will be better if you ask it as a new question and link to this existing question. Try to include what you are specifically trying to achieve in your new question. SharePoint gives you a lot of tools and choosing the right one is important when starting a new project.
    – Kit Menke
    Feb 17, 2012 at 2:15
-2

I do understand your thoughts. I wrote this post a while ago, http://blog.bendsoft.com/2011/03/using-sharepoint-as-a-cms-backenddata-layer/

Here is a good example of how to build a small usercontrol http://blog.bendsoft.com/2011/06/list-your-sharepoint-document-libraries-on-external-sites/

Moreover the above example contain important information about how to create an object with information from SharePoint which is queryable with linq, see below.

var myDoclib = new SharePointDocumentLibrary();
myDoclib.connectionString = @"Server=yoursharepointserver;Database=;Domain=;
                User=username;Password=usersPassword;Authentication=Ntml;TimeOut=30;
                cachetimeout=30;";
myDoclib.Fill("Shared Documents");

var q = myDoclib.DocLib
        .Where(x => x.FileSizeDisplay > 5000)
        .OrderBy(x => x.LinkFilename)
        .Select(x => new { x.ID, x.LinkFilename, x.Modified, x.GUID, x._IsCurrentVersion });

gw.DataSource = q;
gw.DataBind();

Please note that I am an employee of Bendsoft, a company who strive to solve this kind of problems

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.