Using the razor engine in SharePoint 2013 Visual Web Part

I am trying to use a razor mechanism in a SharePoint 2013 web part. This, as I read, should not be too complicated, because the visual 2013 SharePoint web parts can be created using the .NET Framework 4.0.

I'm just not sure where to start. I saw an article about uploading a .cshtml file to a document library and links to a document library in the web part, but this is a bit unclear.

Anyone have any ideas how to get started? Or show me a step-by-step guide to achieve what I want.

My ultimate goal: to take a part of an MVC application, configure it, and make it a web part. I need to be able to modify or access the SharePoint content on this site, so I cannot use part of the application.

+6
source share
3 answers

Good.

First install Office development templates from

http://www.microsoft.com/visualstudio/eng/office-dev-tools-for-visual-studio

This will give you the following template selection to reopen Studio

VS Office and Sharepoint Templates

Then go where EwsManagedApi32.msi is, and enter the following command at the welcome prompt -

EwsManagedApi32.msi addlocal = "ExchangeWebServicesApi_Feature, ExchangeWebServicesApi_Gac"

Your templates are now usable, and the one you want is the "VS2012 Web Part".

Now, by default, this will add an ASP.NET project that you don’t need, so manually delete the ASP.NET project, add MVC, highlight the SharePoint project in Solution Explorer, press F4 and select the MVC project from the Web Project drop-down list at the bottom of the properties.

And you go there. One controller per web part, sorted.

+1
source

I am passing a link to a SharePoint MVC web part that uses the Knock out framework using MVC for SharePoint. It has step-by-step instructions that can help you.

0
source

Source: https://habr.com/ru/post/944392/


All Articles