コード例 #1
0
        public static string Page(this IUrlHelper helper, int pageIndex)
        {
            var    category = helper.ActionContext.RouteData.GetCategory();
            string path     = helper.ActionContext.RouteData.GetPath();

            if (category > 0)
            {
                if (pageIndex > 0)
                {
                    return($"{path.TrimEnd('/')}/{helper.ActionContext.RouteData.GetCategoryUrl() ?? (StringKeys.PathFormat(StringKeys.RouteValue_Category) + category)}/{StringKeys.PathFormat(StringKeys.RouteValue_Page)}{pageIndex}");
                }
                else
                {
                    return($"{path.TrimEnd('/')}/{helper.ActionContext.RouteData.GetCategoryUrl() ?? (StringKeys.PathFormat(StringKeys.RouteValue_Category) + category)}");
                }
            }
            if (pageIndex > 0)
            {
                return($"{path.TrimEnd('/')}/{StringKeys.PathFormat(StringKeys.RouteValue_Page)}{pageIndex}");
            }
            return(path);
        }