I would like to separate the Views for the Static Pages in my DXA Solution to be in a separate project, and use the main project for the DXA Framework configuration and then reference the Views project.

I've tried adding a project reference, but that didn't work, and my views were not found.

I'm using this solution as a guide to get started, but for now I'm creating a new, vanilla DXA Solution and trying to set it up as clean as possible.

4 Answers 4


I haven't tried this with DXA specifically, but we have once implemented a .NET mvc site where views were compiled, and added to the main project as a dll.

The tool we used to do this is called RazorGenerator - https://github.com/RazorGenerator/RazorGenerator.

If I recall well, we had our main mvc website project was referencing our view project, which contained all of the views. As a result, a dll containing all views was copied to our build folder whenever we did a new build.

One of the advantages you get with this is that you get compile time checking of your view code as well.

  • and it puts view updates in the hands of the deployment managers - as opposed to letting IT folks with itchy hands "tweaking" views as and when. Not all IT folks have "itchy hands" but some do and a client may want to remove that opportunity ;) Commented Jul 4, 2017 at 15:11
  • 1
    Here is how to use DXA with Razor Generator community.sdl.com/product-groups/sdl-tridion-dx/tridion-sites/…
    – Jan H
    Commented Nov 30, 2017 at 23:36

MVC.NET doesn't support this. Pretty well explained here: https://stackoverflow.com/questions/24341336/is-it-possible-to-access-mvc-views-located-in-another-project

For the lazy ones:

MVC does not compile views into DLL's, but instead references them as files from the root of your site directory. The location, by convention is ~/Views and a search path is followed. This is more or less hard coded into the default view engines.

Because Views are files, when you break them into a separate project, they won't exist in your primary web application project. Thus, the view engine can't find them. When you compile the app, any projects referenced will only copy the DLL's (and potentially a few other things, like pdb's, etc.)

The best you can do is to separate your project into several Areas.

EDIT as others suggested you could have a post build action to copy your views to the main project.

  • 1
    I had also already read that about MVC, but seems that the word around the DXA campfire was to use separate projects for Modules, and was wondering how the campers managed to do that....
    – robrtc
    Commented Jun 30, 2017 at 9:24

DXA View files are typically cshtml files. For the DXA Web Application to render the views, these files needs to be physically available in the Areas/Views folder.

If you like to maintain the View cshtml files in a separate Project, then you also need to write a post build action in your new project to copy all the view.cshtml files to the DXAWebApp project's Areas/Views folder.


During DXA development we reference our module projects in the main DXA solution, and then have a post build step in all module projects, to copy the Views over to the Area folder of the DXA project, so we have everything in the right place at the right time.


Just noticed this is basically the same answer @Rajesh gave ;o)

  • 3
    In your defence: what we do with DXA Modules goes further than only Views: Modules can also contain View Models and Controllers (which are compiled into a DLL). The post-build step includes copying that DLL. I think it makes sense to use the same approach (i.e. make a genuine Module) instead of having a separate project with only Views. Commented Jun 30, 2017 at 9:30

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.