Friday 24 July 2015

URL Helper in MVC

The URL Helper is Similar to HTML Action Link & Route Link Helpers. http://www.getmscode.com/2015/07/htmlactionlink-mvc.html

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
/Store/Browse?Id=100


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-1.1.1.2.min.js” type=”test/jscript”) />

Rendering Helpers


No comments:

Post a Comment