Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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).

share|improve this question

5 Answers 5

up vote 2 down vote accepted

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

share|improve this answer
    
Thanks, that was helpful. I had the same thing in mind - using the client object model to communicate with SharePoint. –  Emon Jun 22 '11 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. –  Robert Koritnik Oct 4 '11 at 6:07
    
@RobertKoritnik : how do you integrate MVC in SharePoint ? Using this ? sharepointmvc.codeplex.com –  Sylvain Reverdy Oct 4 '11 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. –  Robert Koritnik Oct 4 '11 at 20:21

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.

share|improve this answer
    
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 '11 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. –  Robert Koritnik Oct 4 '11 at 6:08

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

share|improve this answer

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?

share|improve this answer
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 '12 at 2:15
1  
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. –  Waqas Sarwar MCSE Nov 20 at 20:41

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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