Table of Contents


URL Helper

The "Url" class allows you to create, modify, validate, encode, and decode URLs, and much more.

 

Methods

NameArgumentsReturn TypeDescription
Actionstring action,
string controller,
object routeValues
stringConstructs a URL to an action.
Assetstring relativePathstringConstructs a URL to the Magentrix Cloud CDN for a static asset.
Buildstring baseUrl,
object routeValues
stringMerges parameters with an existing URL.
Domain stringCurrent portal's domain
Decodestring urlstringDecodes a URL string.
Encodestring urlstringEncodes a URL string.
Host stringReturns the HttpRequest.Host.
IsLocalUrlstring urlboolReturn true, if the URL is not an external URL.
MergeQueryStringobject values1,
object value2
RouteValueDictionaryMerges two sets of QueryString Parameters. Items in the second parameter overwrite the first one.
You can pass NameValueCollection or RouteValueDictionary or Anonymous class.
ParseQueryStringstring urlNameValueCollectionParses a URL string and extracts all the URL parameters.
ToAbsoluteUrlstring relativeUrlstringReturns an absolute URL version of the relative URL given.
UpsertParameterstring name,
object value
stringReturns the current URL with modified parameter. If the parameter is not found it will be added to the URL, otherwise it will be updated within the URL.
UpsertParameterstring url,
string name,
object value
stringReturns the URL with modified parameter, if the parameter is not found it will be added to the URL. Otherwise it will be updated within the URL.

 

The example below shows how you can construct a URL of an image loaded into Magentrix assets:

<asp:Image runat='server' imageUrl='<%# Url.Asset("home/img/myimage.png") %>' 
 alternativeText='My image' />