Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render view in sitecore 7.2 MVC ..?

i'm creating a MVC application in Sitecore 7.2 MVC, i have install sitecore 7.2 & hosted it on IIS i also added Views,Controller & Models folder. i have created Views & now i'm rendering it using controller action in sitecore i'm a i'm a bit confused here i'm not able to find RouteConfig file so where i'll define HomeController & base Action which perform first..?

Any sitecore MVC expert please help me to how to perform HomeController Action for rendering a view.

thanks in advance

like image 691
Amit Sharma Avatar asked Feb 02 '26 04:02

Amit Sharma


2 Answers

There is no manual registration needed. Once the view and the controller action method is created, simply create a new Controller rendering and fill in the Controller and Method fields with the appropriate controller and method names. Sitecore has a default route registered already and uses dependency injection to pull in the right control using the values from Controller and Method fields.

like image 107
Vasiliy Fomichev Avatar answered Feb 04 '26 20:02

Vasiliy Fomichev


As Vasiliy mentioned, you will need to create a Controller Rendering. Sitecore doesn't use the same routing engine as a standard ASP.NET MVC application.

Steps:

  1. Create the Controller & Controller Action
  2. Create the View
  3. Create the Controller Rendering in Sitecore > Layout > Renderings (typically i organize my renderings in application specific folders such as SiteA, SiteB, etc...)
  4. Add the Rendering to a content item

In the Controller Rendering item, you will need to populate the Controller & Controller Action properties.

enter image description here

like image 42
cpp Avatar answered Feb 04 '26 21:02

cpp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!