How to share cshtml pages across multiple projects?

I have a couple of pages that are common to all my ASP.NET projects. I would like to centralize this code within one assembly. How can i achieve this? Is it possible to simply create and assemble and add it as a reference to my ASP.NET projects, and the pages will be accessible?

+6
source share
1 answer

Using razor views from another (so outside the web project) is not supported out of the box. However, there is a tool for pre-compiling razors, and then you can put them in any DLL. This custom tool is called RazorGenerator .

There are several blog posts where you can start:

Precombine Razor MVC Views with RazorGenerator
Compile your asp.net mvc Razor into a separate dll

+4
source

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


All Articles