Reputation: 36553
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:
Add a IRouteProvider and the following RouteDescriptor
new RouteDescriptor
{
Priority = 5,
Route = new Route(
"Modules/MyApp/{controller}/{action}",
new RouteValueDictionary
{
{"area", "MyApp"}
},
new RouteValueDictionary(),
new RouteValueDictionary
{
{"area", "MyApp"}
},
new MvcRouteHandler())
},
Go to myorchardsite/Modules/MyApp/XYZ/Index in a browser.
ViewFromShared is not found and throws an exception:
Expected Result: ViewFromShared should render on the page
Expected Result: I should have _ViewStart.cshtml and _Layout.cshtml rendered in the page.
Upvotes: 1
Views: 305
Reputation: 17814
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.
Upvotes: 1