protected override void CreateHypermedia()
 {
     var urlHelper =
         new UrlHelper(HttpContext.Current.Request.RequestContext);
     Rel = "_self";
     Href = urlHelper.HttpRouteUrl("DefaultApi", new { controller = "blogposts", id = id });
 }
コード例 #2
0
ファイル: HtmlExtensions.cs プロジェクト: maxmus/IronPigeon
        public static string AbsoluteRouteUrl(this UrlHelper url, string routeName, object routeValues, string protocol = null)
        {
            Uri requestUrl = url.RequestContext.HttpContext.Request.Url;
            var builder    = new UriBuilder(new Uri(requestUrl, url.HttpRouteUrl(routeName, routeValues)));

            builder.Scheme = protocol ?? requestUrl.Scheme;
            builder.Host   = requestUrl.Host;
            builder.Port   = requestUrl.Port;
            return(builder.Uri.AbsoluteUri);
        }
コード例 #3
0
        /// <summary>
        /// The o data url.
        /// </summary>
        /// <param name="urlHelper">
        /// The url helper.
        /// </param>
        /// <param name="routeName">
        /// The route name.
        /// </param>
        /// <param name="segments">
        /// The segments.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string OdataUrl(this UrlHelper urlHelper, string routeName, params ODataPathSegment[] segments)
        {
            var odataPath = PathHandler.Link(new Microsoft.AspNet.OData.Routing.ODataPath(segments));

            return(urlHelper.HttpRouteUrl(
                       routeName,
                       new RouteValueDictionary {
                { ODataRouteConstants.ODataPath, odataPath }
            }));
        }