I have Orchard CMS and I want to integrate my MVC site with it. Can anybody tell me how to do this?
1 Answer
It depends on how complex your MVC app is, but in most cases it is straighforward. The easiest way is to wrap your existing site into Orchard module. Writing a module is described here. These are the necessary steps:
- Copy your site to a subdirectory under ~/Orchard.Web/Modules along with the .csproj file so that the .csproj file should be in your application root (eg. ~/Orchard.Web/Modules/MyApplication/MyApplication.csproj)
- In the root of your app create a Module.txt manifest file. This small file describes your application - its syntax is described here
- Set appropriate routes so that existing controllers' actions can be hit. It's also described in the article above. By default, your application URLs will look like /MyApplication/Controller/Action - you're free to change it as you wish. Be careful though not to interfere with existing routes, eg. /Admin, /Users and so on. The routes you specify have higher priority and will override every exisiting ones. Btw - Area name, where necessary, would be the name of your application (eg. MyApplication).
- Run Orchard and enable your application in Modules/Features admin menu.
- Add necessary changes to web.config file.
Remember though that Orchard is based on ASP.NET MVC 4 and uses Razor view engine. If you use some other view engine, you have to specify it appropriately in the web.config file.
-
4Could you comment on how to handle user authentication with the old site being added? (Can they exist side by side?)– ccookNov 25, 2012 at 22:32
-
@PiotrSzmyd, The steps works. But I am facing a smaller problem. _Layout.cshtml - this is the layout page for the views of the MVC part. But I am unable to mention the path of the _Layout file in each view file. In MVC we can write like this Layout = "~/Views/Shared/_Layout.cshtml"; But it seems that orchard is misinterpreting the name. It is considering the whole string as the name of the file! Also when I write: Layout = "_Layout.cshtml"; Orchard is no looking into the Views/Shared folder. It expects the _Layout.cshtml file to be present in the same folder as the view file! Any workaround?– RahaturJun 25, 2013 at 17:42
-
16I would like to integrate Orchard CMS into MY application. NOT integrate my application INTO Orchard CMS. Sep 10, 2013 at 16:51