asp.net-mvcorchardcmsorchardcms-1.6

Orchard Custom Module Shared Directory


The Orchard implementation of the MVC View Engine doesn't seem to find views or partial views in the "Shared" directory, like the default view engine does.

So, if in my cshtml I refer to a partial view like:

@Html.Partial("ViewFromShared")

This will fail in a custom Orchard module (but work in the normal ASP .NET website).

How can I go about making the Orchard view engine search the Shared directory?

Also, is there any way of making Orchard recognize my ViewStart page?

Thank you.

UPDATE:

I can follow the exact steps below to reproduce:

Expected Result: ViewFromShared should render on the page

Expected Result: I should have _ViewStart.cshtml and _Layout.cshtml rendered in the page.


Solution

  • You can use @Display.ViewFromShared() to create a shape on the fly and make it render in place. You can even set properties on the shape if you need to, using syntax such as @Display.ViewFromShared(SomeProperty: val, SomeOtherProperty: 42). See https://weblogs.asp.net/bleroy/creating-shapes-on-the-fly for more details on creating shapes on the fly.