Getting SharePoint 2013 and MVC 4 to co-exist
-
Thursday, August 30, 2012 1:19 AM
Hello,
Recently, I have installed SharePoint 2013 to test out how ASP.NET MVC will work with it. In SharePoint 2010 I was able to host an MVC site as an IIS application under the SharePoint site. As long as I registered the MVC dll in the GAC everything worked well. I liked this model because I was able to create webparts to access the MVC application via AJAX with no need to enter credentials again.
Currently, I am trying to do the same thing – hosting a MVC 4 application under the SharePoint 2013 site. When I try to access the MVC application I get the error: “Dynamic operations can only be performed in homogenous AppDomain” when the application is setting a property in the ViewBag. I was able to get the MVC application to work if I removed the <trust …> tag in the SharePoint web.config file. However, by removing that tag, who knows what will break in SharePoint.
Is there any way to get the two to coexist? Is there any support for MVC in SharePoint 2013?
Thanks,
Bob
All Replies
-
Saturday, September 01, 2012 12:34 AMModeratorHello Bob we wouldn't recommend you to host additional applications under the SharePoint 2013 website; things, as you have observed can break. Instead you should look at using the new App model to decouple your extensions to the platform. http://dev.office.com
- Proposed As Answer by Humberto LezamaMicrosoft Employee, Moderator Saturday, September 01, 2012 12:34 AM
- Unproposed As Answer by king_ozymandias Saturday, September 01, 2012 1:20 AM
-
Saturday, September 01, 2012 12:43 AM
The new app model looks like it is for office 365 and cloud services.
In other words my best bet is to host the MVC app on another server and build a custom web part that can make JSONP calls to the MVC app. I really wanted to avoid this, but I want to support single sign on and the MVC app uses windows authentication.
I was hoping for better MVC support in SharePoint 2013.
-
Saturday, September 01, 2012 12:54 AMModerator
The new model works too for on-premise deployments. By decoupling your app you have a lot more flexibility as opposed to interweaving your app in ways that could very well block upgrades of your company/customers longer term. You can write your app on MVC, ASP forms, or any language for that matter.
If you are interested in trying the app model for on-prem this is a good starting point article:
http://msdn.microsoft.com/en-us/library/office/apps/fp179923(v=office.15)
- Proposed As Answer by Humberto LezamaMicrosoft Employee, Moderator Saturday, September 01, 2012 12:54 AM
-
Saturday, September 01, 2012 1:04 AM
I understand doing this for an application that needs to access SharePoint components, however, this MVC app does not. The company I work for uses the home site as a portal. Some of the custom webparts get data from the MVC app to display information. A long time ago I was able to use a web from application page (aspx) to do this. Then as MVC came out, the application was rewritten. I just wish Microsoft supported an MVC “page” (application) like they do for webform’s application page.
thanks for your help,
bob
-
Saturday, September 01, 2012 1:24 AMModerator
Thank you for the feedback Bob. I understand your request but as I mentioned the platform is moving away from hosting pages on the SharePoint server itself; doing so (or changing SharePoint's config to make them work) is not something that we would recommend.
If I'm reading your thread correctly the MVC app is essentially a webservice that you use as a data source for webparts.
Perhaps this is the piece that I don't understand, why does your MVC app MUST be hosted under the same website as SharePoint? If the answer is something related to "authentication"that is precisely the type of problem that the app model could help you solve; it is designed for both, apps that consume sharepoint services but also for apps that bring data from other sources. By building an App you don't have to worry what type of pages SP supports (on this or any future release) because you app is essentially decoupled from SharePoint.
- Marked As Answer by king_ozymandias Saturday, September 01, 2012 1:25 AM
- Edited by Humberto LezamaMicrosoft Employee, Moderator Saturday, September 01, 2012 1:25 AM
-
Saturday, September 01, 2012 1:39 AMI would like to use the same MVC app for authentication and I do not want to rewrite another application just for sharepoint. This MVC app services other views (desktop, mobile, etc).

