当前位置: 首页>>代码示例>>C#>>正文


C# UrlHelper.AbsoluteRouteUrl方法代码示例

本文整理汇总了C#中System.Web.Mvc.UrlHelper.AbsoluteRouteUrl方法的典型用法代码示例。如果您正苦于以下问题:C# UrlHelper.AbsoluteRouteUrl方法的具体用法?C# UrlHelper.AbsoluteRouteUrl怎么用?C# UrlHelper.AbsoluteRouteUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.UrlHelper的用法示例。


在下文中一共展示了UrlHelper.AbsoluteRouteUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSitemapNodes

        public IReadOnlyCollection<SitemapNode> GetSitemapNodes(UrlHelper urlHelper)
        {
            List<SitemapNode> nodes = new List<SitemapNode>();
            nodes.Add(
                new SitemapNode()
                {
                    Url = new System.UriBuilder(Request.Url.AbsoluteUri)
                    {
                        Path = Url.Content("~/"),
                        Query = null,
                    }.ToString(),
                    Priority = 1
                });
            nodes.Add(
                new SitemapNode()
                {
                    Url = new System.UriBuilder(Request.Url.AbsoluteUri)
                    {
                        Path = Url.Content("~/Constructor"),
                        Query = null,
                    }.ToString(),
                    Priority = 0.9
                });
            foreach (dynamic project in getPublicPolls())
            {
                nodes.Add(
                    new SitemapNode()
                    {
                        Url = urlHelper.AbsoluteRouteUrl("getPoll", new { poll = project.UrlCode }),
                        Frequency = SitemapFrequency.Weekly,
                        Priority = 0.8
                    });
            }

            return nodes;
        }
开发者ID:AlexanderAnishchik,项目名称:PollY,代码行数:36,代码来源:HomeController.cs

示例2: GetSitemapNodes

        public static IReadOnlyCollection<SitemapNode> GetSitemapNodes(UrlHelper urlHelper)
        {
            List<SitemapNode> nodes = new List<SitemapNode>();

            nodes.Add(
                new SitemapNode()
                {
                    Url = urlHelper.AbsoluteContent("/Home"),
                    Priority = 1
                });
            nodes.Add(
               new SitemapNode()
               {
                   Url = urlHelper.AbsoluteContent("/Home/About"),
                   Priority = 0.9
               });

             HahaVilleContext db = new HahaVilleContext();
             var listOfGategories = (from c in db.Category
                                     select c.Name.Replace(" ", "-"));
                foreach (var cat in listOfGategories)
            {
                nodes.Add(
                   new SitemapNode()
                   {
                       Url = urlHelper.AbsoluteRouteUrl("Category", new { action = "Category", name = cat }),
                       Frequency = SitemapFrequency.Monthly,
                       Priority = 0.9
                   });
                }

             var objTargetGame = (from g in db.Games
                                  select
                                      g.Name.Replace(" ", "-")
                                  );
             foreach (var game in objTargetGame)
            {
                nodes.Add(
                   new SitemapNode()
                   {
                       Url = urlHelper.AbsoluteRouteUrl("Game", new { action = "Details", name = game }),
                       Frequency = SitemapFrequency.Weekly,
                       Priority = 0.8
                   });
                nodes.Add(
                new SitemapNode()
                {
                    Url = urlHelper.AbsoluteRouteUrl("Play", new { action = "Play", name = game }),
                    Frequency = SitemapFrequency.Weekly,
                    Priority = 0.8
                });
            }

            nodes.Add(
               new SitemapNode()
               {
                   Url = urlHelper.AbsoluteContent("/Home/Contact"),
                   Priority = 0.7
               });

            return nodes;
        }
开发者ID:skysrc,项目名称:HahaVille,代码行数:62,代码来源:SitemapHelper.cs


注:本文中的System.Web.Mvc.UrlHelper.AbsoluteRouteUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。