-2

I am working on MVC and i started learning Umbraco, I didn't get how to bind the umbraco page with mvc controller get method to show the database values. can anyone suggest any url or video?

Thansk...

2 Answers2

0

What you're looking for is Umbraco route hijacking.

You can read about it here. https://our.umbraco.org/documentation/reference/routing/custom-controllers

It's easiest to demonstrate with an example : let's say you have a Document Type called 'Home'. You can create a custom locally declared controller in your MVC web project called 'HomeController' and ensure that it inherits from Umbraco.Web.Mvc.RenderMvcController and now all pages that are of document type 'Home' will be routed through your custom controller! Pretty easy right :-) OK so let's see how we can extend this concept. In order for you to run some code in your controller you'll need to override the Index Action.

So, basically, you "simply" need to create a controller named after your document type, so for example, a document type with the name "TextPage" would need a controller called "TextPageController". Now, if you read through the documentation, you'll find that your "TextPageController" will need to inherit from the RenderMvcController. Here's an example how to achieve this.

public class TextPageController : RenderMvcController
{
    public ActionResult Index()
    {
        return View("~/Views/TextPage.cshtml");
    }
}
Mikkel
  • 1,853
  • 1
  • 15
  • 31
-1

This forum link may help you:

https://our.umbraco.org/forum/developers/razor/38242-Umbraco-MVC4111-Surface-controller-using-an-AJAX-form

Callum Watkins
  • 2,844
  • 4
  • 29
  • 49