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:
- Create a new ASP .NET MVC 4 project (MyApp).
- Add a new cshtml in the Shared directory (SharedFile.cshtml).
- Add a new View (Views/XYZ/MyView) and Controller (Controllers/XYZController).
- Call View("MyView") from the new Controller Index method.
- Add Html.Partial("SharedFile") to MyView
- Publish website to Orchard/Modules/MyApp.
- Add a Module.txt (Name: MyApp)
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
- If I remove the call to @Html.Partial("ViewFromShared") _ViewStart.cshtml and _Layout.cshtml are not respected and there is no html/head/body tags...just the content of MyView.cshtml.
Expected Result: I should have _ViewStart.cshtml and _Layout.cshtml rendered in the page.