Passing Parameters to the ActionLink in ASP.NET MVC

There are times when the parameter has to be passed along with the URL from an ActionLink control in ASP.NET MVC. This can be done easily using the anonymous type which can be passed as the third parameter for the ActionLink helper method.

Passing Parameters to the ActionLink in ASP.NET MVC

Below is a sample code snippet demonstrating how to pass values to the ActionLink in ASP.NET MVC

@model MvcApplication1.Models.EmployeeVM

@{

if (@ViewContext.ViewData.ModelState.IsValid)

{

ViewBag.Title = "Index";

}

}

<h2>@ViewBag.ApplicationTitle</h2>

@Html.ActionLink(“Abundantcode.com – Primary source for Programming samples”,”Home”, new { id = “Welcome to Abundantcode.com” })