Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share cshtml pages across multiple projects?

I have a couple of pages common across all my ASP.NET projects. I would like to centralize that code inside a single assembly. How can I achieve this? Is it possible to simply create and assembly and add it as a reference of my ASP.NET projects and the pages are going to be accessible?

like image 767
Martin Avatar asked Feb 15 '12 20:02

Martin


1 Answers

Using razor views from a different (so from outside the web project) is not supported out of the box. However there a tool to precompile razor views and then you can put them in any dll. This custom tool is called RazorGenerator.

There are some blog posts where you can start:

Precompile your MVC Razor views using RazorGenerator
Compile your asp.net mvc Razor views into a seperate dll

like image 130
nemesv Avatar answered Nov 09 '22 02:11

nemesv