I'm trying to make use of the razor engine in a SharePoint 2013 Web Part. This, I read, shouldn't be too difficult since SharePoint 2013 Visual Web Parts can be built using .NET Framework 4.0

I'm simply not sure of where to begin to do this. I've seen an article on uploading the .cshtml file onto a document library and referencing the document library in the Web Part, but it is a bit unclear.

Does anyone have an idea of how I can start? Or point me to a step-by-step guide to achieve what I am after.

What my end goal is: Take a piece of an MVC application, customize it and make it a Web Part. I need to be able to modify or access SharePoint content on that site which is why I cannot use an App Part.

Your assistance and wisdom regarding this matter is truly appreciated.

1 Answer 1


You can access SharePoint data using an App, you just cannot use SharePoint Server-Side Object Model code. But you could easily access and manipulate data using the SharePoint web services or client object model.

If you really want to use Razor within SharePoint, it looks like all you need to do is use NuGet to add Razor to your project. You then build your model as expected and your .cshtml as usual. Upload the .cshtml to a document library and it runs as it would in an MVC application. But I am not certain this is going to work in a VisualWeb part.



  • alright I will give that a shot, it wouldn't work in a VisualWebPart because it has aspx web forms... okay that makes sense. I'll try this and will accept this if I succeed
    – anpatel
    Commented May 6, 2013 at 21:25
  • You should do a blog post on the topic if you do get it working! I would be interested in reading about the process. Commented May 7, 2013 at 13:01
  • Alright, will do
    – anpatel
    Commented May 7, 2013 at 17:12

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.