Orchard - link to view / action in another module?

Let's say I'm on Module1 -> Controller1 -> View1.

In View1, I want to add a regular hyperlink to Module2 -> Controller2 -> View2.

How to do it?

Thank.

+3


source to share


1 answer


ASP.NET MVC links point to an action on a controller , not a view. As a result, the result can (but does not have to) return from the given action.

So if your View2 comes back eg. action MyAction on Controller2 sitting in Module2 , then you can easily add a link to this action from anywhere by writing:

@Html.ActionLink("Click Me", 
                 "MyAction", 
                 "Controller2", 
                 new { area = "Module2" }, 
                 new {})

      

or



@Html.ActionLink("Click Me", 
                 "MyAction", 
                 new { controller = "Controller2", area = "Module2" })

      

which is best for you. There are a couple of other possible overrides .

The Route Area property is used in Orchard to specify the name of the target module.

+4


source







All Articles