Created
November 17, 2011 00:02
-
-
Save Zaidos/1371940 to your computer and use it in GitHub Desktop.
Url Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
/// <summary> | |
/// URL Extension Class | |
/// </summary> | |
public static class Url | |
{ | |
/// <summary> | |
/// Returns a relative URL to Home. | |
/// </summary> | |
/// <param name="helper">UrlHelper</param> | |
/// <returns>Home content path.</returns> | |
public static string Home(this UrlHelper helper) | |
{ | |
return helper.Content("~/"); | |
} | |
/// <summary> | |
/// Returns a relative URL to an image. | |
/// </summary> | |
/// <param name="helper">UrlHelper</param> | |
/// <param name="fileName">File name.</param> | |
/// <returns>Image content path.</returns> | |
public static string Image(this UrlHelper helper, string fileName) | |
{ | |
return helper.Content(contentPath: "~/Content/Images/" + fileName); | |
} | |
/// <summary> | |
/// Returns a relative URL to a style sheet. | |
/// </summary> | |
/// <param name="helper">UrlHelper</param> | |
/// <param name="fileName">File Name.</param> | |
/// <returns>Style content path.</returns> | |
public static string Style(this UrlHelper helper, string fileName) | |
{ | |
return helper.Content(contentPath: "~/Content/CSS/" + fileName); | |
} | |
/// <summary> | |
/// Returns a relative URL to a script. | |
/// </summary> | |
/// <param name="helper">UrlHelper</param> | |
/// <param name="fileName">File name.</param> | |
/// <returns>Script content path.</returns> | |
public static string Script(this UrlHelper helper, string fileName) | |
{ | |
return helper.Content(contentPath: "~/Scripts/" + fileName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment