What is ActionLink

ActionLink is used to generate hyperlink in MVC using HTML Helper Class.

Syntax of ActionLink

@Html.ActionLink("Login","Welcome")

Example of ActionLink

In this example Login is the Text which shows on link and Welcome is the view on which it will redirected when we click on this actionlink.

Actionlink method also allows us to bind any data on this link. We can access this data on redirected page.

@Html.ActionLink("Login", "Welcome", new { UserId = "isha123" })

In this example I bound data using name UserId. I can access this id on Welcome view as a parameter.




		
	public ActionResult Welcome(string UserId)
        {
            Response.Write("Hello " + UserId);

            return View();
        }

    

In this way we can bind data on this actionlink which we can access on the redirected page.