Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (22 sloc)
947 Bytes
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.Collections.Generic; | |
using System.Web; | |
using System.Web.Mvc; | |
using System.Web.Routing; | |
namespace Restfulie.Server.Marshalling.UrlGenerators | |
{ | |
public class AspNetMvcUrlGenerator : IUrlGenerator | |
{ | |
#region IUrlGenerator Members | |
public string For(string controller, string action, IDictionary<string, object> values) | |
{ | |
var httpContextWrapper = new HttpContextWrapper(HttpContext.Current); | |
var urlHelper = new UrlHelper(new RequestContext(httpContextWrapper, RouteTable.Routes.GetRouteData(httpContextWrapper))); | |
return FullApplicationPath(httpContextWrapper.Request) + urlHelper.Action(action, controller, new RouteValueDictionary(values)); | |
} | |
#endregion | |
private string FullApplicationPath(HttpRequestBase request) | |
{ | |
return request.Url.Scheme + "://" + request.Url.Authority; | |
} | |
} | |
} |