# Get Category Url

**URL:** <https://forum.litium.com/t/get-category-url/777>\
**Category:** Questions\
**Tags:** accelerator, litium-7\
**Created:** [April 4, 2019, 1:10pm UTC](https://forum.litium.com/t/get-category-url/777 "2019-04-04T13:10:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/artur/32/948_2.png) [@Artur](https://forum.litium.com/u/Artur)\
**Post date:** [April 4, 2019, 1:10pm UTC](https://forum.litium.com/t/get-category-url/777/1 "2019-04-04T13:10:41Z")

</div>

Hi,

I’m finding trouble to get URL for specific Category.  
I have a block that will display **n** categories that then will link to the category page. I found two ways to achieve _almost_ what i want.

In my ViewModel i have:

```auto
var category = model.Fields.GetValue<Guid>BlockFieldNameConstants.LinkToCategory).MapTo<Category>();

```

**I found that there are these extensions =\>**

```auto
using Litium.Foundation.Modules.ExtensionMethods;
using Litium.Accelerator.Extensions;
...
var href = category.GetUrl(CultureInfo.CurrentUICulture)

```

Gives me url for respective category eg:  
category-1

but no path that i could use.

**Another way =\>**  
Inject and use in the builder.

```auto
Litium.Web.UrlService _urlService;
...
var href = _urlService.GetUrl(category.Category);

```

**Gives me an long id string when in backoffice, and null otherwise**  
“/!2726b040-9c16-47de-a701-e30d02727e69!1!00000000-0000-0000-0000-000000000000!0!0/00000000-0000-0000-0000-000000000000/0aee0775-5699-4670-9826-1a53d388c3e1”

Litium version: 7.1

---

<div class="post-metadata">

**Author:** ![ton.nguyen](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ton.nguyen/32/989_2.png) [@ton.nguyen](https://forum.litium.com/u/ton.nguyen)\
**Post date:** [April 4, 2019, 1:31pm UTC](https://forum.litium.com/t/get-category-url/777/2 "2019-04-04T13:31:10Z")

</div>

You need to pass the second param, which is a CategoryUrlArgs. Its property ChannelSystemId has to have value, otherwise null will be returned. If the Category is not activated in that channel, null will also be returned.

---

<div class="post-metadata">

**Author:** ![Artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/artur/32/948_2.png) [@Artur](https://forum.litium.com/u/Artur)\
**Post date:** [April 4, 2019, 2:38pm UTC](https://forum.litium.com/t/get-category-url/777/3 "2019-04-04T14:38:14Z")

</div>

Hi, thank you for the response.  
Could you please specify a bit?

RequestModelAccessor requestModelAccessor injection in the builder and tried to send i

We tried with:

```auto
_urlService.GetUrl(category.Category, new CategoryUrlArgs(_requestModelAccessor.RequestModel.ChannelModel.Channel.SystemId))

_urlService.GetUrl(category.Category, new CategoryUrlArgs(_requestModelAccessor.RequestModel.ChannelModel.SystemId))

```

Thanks again.

---

<div class="post-metadata">

**Author:** ![ton.nguyen](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ton.nguyen/32/989_2.png) [@ton.nguyen](https://forum.litium.com/u/ton.nguyen)\
**Post date:** [April 5, 2019, 11:19am UTC](https://forum.litium.com/t/get-category-url/777/4 "2019-04-05T11:19:47Z")

</div>

That seems to be correct. You still got null as the result? Is the category activated on current channel, and be published? What Url does it have?

---

<div class="post-metadata">

**Author:** ![Artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/artur/32/948_2.png) [@Artur](https://forum.litium.com/u/Artur)\
**Post date:** [April 5, 2019, 12:13pm UTC](https://forum.litium.com/t/get-category-url/777/5 "2019-04-05T12:13:59Z")

</div>

It works now, seems it’s an db issue.

Had issues that a category was only available through back-office links and same with the link to an category.

We checked following settings

- it was published on all channels.
- it had an url
- assortment was set

As soon as we tested with another db it worked.
