Friday, 24 July 2015

URL Helper in MVC

The URL Helper is Similar to HTML Action Link & Route Link Helpers.

But instead of returning HTML, they build URLs & return URLs as string.

Three Helpers for URL.
Ø  Content
Ø  Action
Ø  Route URL

Action URL is same link Action link, But doesn’t return an anchor Tag.
@URL.Action(“Browse”,”Store”, new { ID = 100}, null)

It Generates HTML Tag as

The RouteURL helper follows the same Pattern as the action Helper but like RouteLink it accepts a route name and doesn’t have argument for controller name and action name.

Content Helper is helpful because it can convert the relative application path to an absolute application path.

<script src=”@URL.content(~/script/Jquery/Jquery-” type=”test/jscript”) />

Rendering Helpers

No comments:

Post a Comment