Recently one chap has asked a question oh how to include MVC into existing Sitecore project. A guy coming from classical ASP.NET MVC background experienced confusion with MVC implemented in Sitecore (here's an original link on StackOverflow). I decided to give a comprehensive answer on how MVC work with Sitecore:
Answer: In the very simplest way, you need to have the following:
- Item for your page, the one that has URL; that is as normal in Sitecore
That page Item should have Layout assigned. From Presentation --> Details menu select at least a layout on that stage. If you do not have layout yet, you need to create a layout definition item under /Layout/Layouts
folder and associate it with certain *.cshml file. Also mention that
layout should have a placeholder where you will "inject"your rendering.
@Html.Sitecore().Placeholder("Main")
You need to create a Controller Rendering under /Layout/Renderings folder in Sitecore. Make sure you set Controller and Controller Action fields to your controller name and action method name.
Finally, go again to Presentation --> Details --> Edit --> Controls and add your newly created rendering into a placeholder that you have on your layout *.cshtml file.
That's all done.