Developer forum

Forum » Integration » Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl in data integration activity

Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl in data integration activity

Davor Zlotrg
Reply

Hi DynamicWeb,

I am trying to call Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl method in my Data Integration activity (RunJob method of Configurable AddIn). 

Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(1) - This works and returns correct friendly URL (/forside). 

Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?ID=9&ProductID=86245714020-at-SHOP1") - This does not work and throws "Object reference not set to an instance of an object.." (this ProductID exists in DB and this function works correctly when called from the frontend).

Kind regards,

 

 

 


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Davor

You need an instance of Pageview to be present to call GetFriendlyUrl(string) (Not when calling GetFriendlyUrl(int).

So before running your code, instantiate a pageview with a valid page ID, only once for the entire job:

_Pageview = New Dynamicweb.Frontend.PageView(1)

_Pageview.Load()

But I cannot understand why you need to find the URL during import, or at any other time...

 
Davor Zlotrg
Reply

Hi Nicolai,

 

Thanks for your answer.

I need this because during the import of products and categories in dynamicweb I am also generating xml feeds for other partners to use and inside the xml I need to provide the url for every product, category etc and they want it to be pretty url.

 

Your solution might work but constructor for PageView that accepts an int is marked as internal and I can not use it. Is there a workarround for this?

 
Nicolai Høeg Pedersen
Reply

New pageview

pageview.ID = 1

pageview.load

Same thing!

 
Davor Zlotrg
Reply

We already tried that and it was throwing "Thread was being aborted"

 

var _Pageview = new Dynamicweb.Frontend.PageView();
 _Pageview.ID = 9;            
 _Pageview.Load();

var friendlyUrl =Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?ID=9&ProductID=86245714020-at-SHOP1")

 

You must be logged in to post in the forum