Developer forum

Forum » Development » Using getSearchFriendlyUrl in ashx file

Using getSearchFriendlyUrl in ashx file

Martijn Bokhove
Reply
Hi

I'm trying to use the great function getSearchFriendlyUrl to create friendly URL's for products in an Ashx handler.
Using it in normal Ascx handlers, it works very nice.
Using it it Ashx handlers, it throws the error 'Object reference not set to an instance of an object. / NullReferenceExecption was unhandled by user code'

The reason we are using the Ashx handler, is to create a XML sitemap for the Google Product Feed.

Are there any options to use the getSearchFriendlyUrl in an Ashx file?

Gr.
Martijn

Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer
Hi Martijn

Do not think it is possible - searchFriendlyUrl class is dependent on some of the normal aspx page logic.

But you could use a navigation provider instead - see this article:
http://devierkoeden.com/articles/extending-the-google-sitemap-feature-with-custom-content.aspx

Votes for this answer: 0
 
Pavel Volgarev
Reply
Hi Martijn,

Try implementing the IRequiresSessionState interface in your handler (it has no methods, it's just a marker interface to tell ASP.NET that your handler relies on session state).

More info:
http://msdn.microsoft.com/en-us/library/system.web.sessionstate.irequiressessionstate.aspx

But as Nicolai mentioned, you should rather go for "Navigation provider" approach.

-- Pavel 

 

You must be logged in to post in the forum