# Getting a category from a URL

**URL:** <https://forum.litium.com/t/getting-a-category-from-a-url/1852>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [January 21, 2021, 12:40pm UTC](https://forum.litium.com/t/getting-a-category-from-a-url/1852 "2021-01-21T12:40:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johan](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/johan/32/357_2.png) [@Johan](https://forum.litium.com/u/Johan)\
**Post date:** [January 21, 2021, 12:40pm UTC](https://forum.litium.com/t/getting-a-category-from-a-url/1852/1 "2021-01-21T12:40:50Z")

</div>

Hi

How can I get the category from a url? For example, lets say I want the SystemId for the tshirts category in [www.example.com/clothes/tshirts](http://www.example.com/clothes/tshirts).

I have been trying using the PageRouteResolver; but I am unsure what properties I need to set in routeRequestLookupInfo.

`var x = _pageRouteResolver.TryGet(routeRequestLookupInfo, out RouteRequestInfo routeRequestInfo);`

Litium version: 7.6.1

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [January 21, 2021, 3:04pm UTC](https://forum.litium.com/t/getting-a-category-from-a-url/1852/2 "2021-01-21T15:04:30Z")

</div>

Maybe something like this:

```auto
var url = "example.com/clothes/tshirts";
var info = new RouteRequestLookupInfo()
{
	Channel = channel,
	Path = url,
	PathSegments = url.Split('/'),
};

_pageRouteResolver.TryGet(info, out var routeRequestInfo);

var categorySystemId = routeRequestInfo.Data is ProductPageData data ? data.CategorySystemId : Guid.Empty;

```

---

<div class="post-metadata">

**Author:** ![Johan](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/johan/32/357_2.png) [@Johan](https://forum.litium.com/u/Johan)\
**Post date:** [January 22, 2021, 12:11pm UTC](https://forum.litium.com/t/getting-a-category-from-a-url/1852/3 "2021-01-22T12:11:55Z")

</div>

@NilsN That works as expected! Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [February 19, 2021, 12:12pm UTC](https://forum.litium.com/t/getting-a-category-from-a-url/1852/4 "2021-02-19T12:12:10Z")

</div>

Closed on February 19, 2021, 12:12pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
