Developer forum

Forum » Development » Get pageid from url using API

Get pageid from url using API

Lars Larsen
Lars Larsen
Reply

Hi

I need to get the pageid from a URL using the API. How can I do that?


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

Hi Lars,

I'm not sure that you can. Why do you need this? Can you provide some more details / code?

/Morten

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Lars,

Are you in the context of a page load or do you have a url string, e.g. saved in a log file or database, that you need to reverse lookup?

- Jeppe

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Lars

There is no simple way to do that. But you can do something like this:

Dim curArea As Area = PageView.GetAreaByDomain()
Dim index As UrlIndex = UrlIndex.GetIndex(UrlPageTreeHelper.Instance.GetAreaUrlIndexName(curArea))
Dim queryString = index.PathIndex.Item(requestPath).GetQueryString()

The result will be an entire querystring - could be "ID=1" or it could be "ID=1&groupid=group4" etc.

But why/where do you need it? I am pretty sure you can get access to the pageid in a better way.

BR Nicolai

 
Lars Larsen
Lars Larsen
Reply

Hi Jeppe

It's exactly that. I have an IIS redirect file that I want to convert to Redirects in Dynamicweb. My source file contains url's but to create the redirects in the table UrlPath I need the pageid for the url's.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

You can try with the code I provided.

But there are domain rules, language rules etc. that could give you wrong or missing results.

 
Lars Larsen
Lars Larsen
Reply

Hi Nicolai

Yes, I will try your code and be aware of domain rules, languge rules etc. as you write. Thanks.

 

You must be logged in to post in the forum