Monday, September 28, 2015

Linking to an MVC Controller in an Area

 

If you have been wondering how to link to a Controller that is in an MVC Area, the answer is surprisingly easy!

You can link to a Controller in an Area of your MVC Web Application project in the following manner:

@Url.Action("Index", "AreaHome", new {Area = "MyArea"}, null)


Alternatively, you can also use the following code:



@Html.ActionLink("Index", "AreaHome", new {Area = "MyArea"}, null)

That is all there is to it!!

No comments:

Post a Comment