I am trying to write my own LightWeight MVC for .Net 2.0 using NHaml as the view engine.
In ASP.Net 3.5 MVC the View file we used to specify the link by the code snippet.
Html.ActionLink('Add Product','Add');
In MVC binary there is no function to match this call.
I Only found:
(In class System.Web.Mvc.Html.LinkExtensions )
public static string ActionLink(this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName)
There are more similar static classes like FormExtensions, InputExtensions etc.
How does ASP.Net MVC handle it? Does it generates dynamic code for Html.ActionLink?
The
ActionLinkmethod is an extension method (hence thethisbefore the type of the first parameter). This means you can use this method as an instance method on allHtmlHelperinstances, even though it is not defined onHtmlHelper.Htmlis a property on the View of typeHtmlHelper. This means you can use theActionLinkextensionmethod on it.The
ActionLinkmethod itself does nothing more than generate a link string (with regards to its arguments) and return that string.