Developer forum

Forum » Templates » Razor Redirect Frindly URL

Razor Redirect Frindly URL

Nuno Aguiar
Reply

Hi,

 

Creating a redirect in razor, how could we generate/get the FriendlyURL for a given page?

 

Nuno


Replies

 
Mikkel Ricky
Reply
This post has been marked as an answer

The methods in Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl can do this for you, e.g.

@Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(42)
@Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?Id=42")

Best regards,
Mikkel

 

Votes for this answer: 1
 
Nuno Aguiar
Reply

Hi Mikkel,

 

Thanks,

Nuno

 
Adrian Ursu
Reply

Hi Guys,

I cannot make it work for a product link.

Anything I am missing?

The code is: 

var friendlyURL = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?id="+catalogPage+"&prodid="+productId+"");

Thanks,


Adrian

 
Adrian Ursu
Reply

Sorry.

I've got it. I was using the wrong prefix. Should be ProductID instead of prodid

 
Nicolai Høeg Pedersen
Reply

What does it return?

I think the product parameter in ecommerce is &productid=

 
Adrian Ursu
Reply

Yes. It was the wrong queryString parameter. ProductID renders it correctly.

Thanks a lot

 

You must be logged in to post in the forum