Created
December 11, 2013 21:37
-
-
Save jbogard/7918898 to your computer and use it in GitHub Desktop.
Hyprlinkr + UrlHelper
This file contains 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; | |
using System.Linq.Expressions; | |
using System.Web.Http; | |
using System.Web.Http.Routing; | |
using Ploeh.Hyprlinkr; | |
public static class UrlHelperExtensions | |
{ | |
public static Uri Link<T, TResult>(this UrlHelper helper, Expression<Func<T, TResult>> expression) | |
where T : ApiController | |
{ | |
var linker = new RouteLinker(helper.Request); | |
return linker.GetUri(expression); | |
} | |
public static Uri Link<T>(this UrlHelper helper, Expression<Action<T>> expression) | |
where T : ApiController | |
{ | |
var linker = new RouteLinker(helper.Request); | |
return linker.GetUri(expression); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
now in a controller action, just do