A very strange problem, I spent hours, but could not find what the problem was. I have the code as follows:
public static string AbsoluteAction(this UrlHelper urlHelper, string actionName, string controllerName, object routeValues)
{
return ResolveUrl(urlHelper, urlHelper.Action(actionName, controllerName, routeValues));
}
private static string ResolveUrl(UrlHelper urlHelper, string relativeUrl)
{
return new Uri(GetRequestUri(urlHelper), relativeUrl).AbsoluteUri;
}
private static Uri GetRequestUri(UrlHelper urlHelper)
{
return urlHelper.RequestContext.HttpContext.Request.Url;
}
When using string.Empty as routeValues, "urlHelper.Action (actionName, controllerName, routeValues)" works well on my local dev machine. (Windows 7, IIS 7.5, .Net 4.0, MVC3) It returns the correct URL.
But it returns an empty string on our continuous integration server. (Windows Server 2008, IIS 7.0, .Net 4.0, MVC3)
:
routes.MapRoute(
"MyRouteName",
"Getaddresses/{} /",
new {controller = "Address", action = "GetAddresses", postcode = string.Empty},
new {httpMethod = new HttpMethodConstraint ( "GET" )}, [] { "My.Package.Controllers" });
, string.Empty RouteValues, .
, dev- CI. -?
, :
.Net 3.5, Visual Studio 2010, MVC2. .Net 4.0, Visual Studio 2012, MVC3. Dev . .Net 4.0 MVC3 CI- ( dev-, ). - CI. , smoke test , , "localhost/getaddresses" AbsoluteAction ( " ", " ", {postcode = string.Empty}), ""
, .:)
!