Sharing Razor views across projects

前端 未结 3 1540
渐次进展
渐次进展 2020-12-15 17:37

I want to share the layout (Header, Navigation and Footer Razor views) across multiple ASP.NET MVC projects. How can I do that?

Can I create a custom NuGet package t

3条回答
  •  执念已碎
    2020-12-15 18:37

    Three approaches:

    1. Share the Razor view source code using your version control system
    2. Compile the views into a separate DLL file for binary sharing.
    3. Create a NuGet package

    See Compile your ASP.NET MVC Razor views into a separate DLL for how you do option 2.

    For option 3, see Creating and Publishing a Package.

    In fact, I think this is the original article on how to compile Razor views: Precompile your MVC Razor views using RazorGenerator

提交回复
热议问题