Intranoggin

Blither, Blather, Web Content Management.
Blog » 3 Steps to Set Up ASP .NET MVC in a SharePoint Autohosted App

3 Steps to Set Up ASP .NET MVC in a SharePoint Autohosted App

If you’re going after a SharePoint 2013 developer certification, you know one of the exams you must pass is for ASP .NET MVC (70-486). MVC comes into play when you start creating Autohosted or Provider Hosted SharePoint Apps running on Azure. However, they default Autohosted App runs Web forms, not MVC. MVC is important, just not important enough to warrant baking into the project template *snark*. Just kidding. I don’t know why it’s not built into the template by default, but I can tell you the story has gotten much better.

*Update: 8/22/2013 – I just realized that Microsoft added support for MVC in SharePoint Apps out of the box in the Visual Studio 2013 preview. This post is still relevant for Visual Studio 2012

Step 1) Create your Autohosted SharePoint App. Be sure to set the .NET Framework drop down to 4.

image

image

Step 2) Add an ASP .NET MVC project to your solution. Again, make sure .NET Framework 4 is selected. I’ve tested these instructions with the Internet, HotTowel, and Durandal flavors of MVC, but I think the others should all work as well. Web API may prove very useful, but I haven’t tested it yet.

image

image

image

Step 3) In your application project, set your new MVC project as the Web Project. and F5 to deploy.

image

You can then remove the original web project that Visual Studio created for you (in my example it was called SP_MVCWeb). Since the app will deploy without doing this, it’s not an official step, thus my 3 step claim remains accurate.


Posted: 1/26/2013 4:01:00 AM by Ryan Miller | with 0 comments
Filed under: SharePoint