Developer forum

Forum » Development » Direct paths, redirects and api

Direct paths, redirects and api

Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Hi,

What is the order in which the redirects are handled?

Is it correct, that if a page is not found, the settings for direct paths is checked. If no rule exists here, the 404-page is shown?

If I want to hook into this, and create my own extension for the direct paths, to be executed after the direct paths have been checked, it is not a good idea to subscribe to the "Standard.Page.NotFound", as this is triggered before the directs paths, right?

--
Best regards
Kurt Moskjaer Andersen


Replies

 
Nicolai Pedersen
Reply

Standard.Page.NotFound is raised before direct paths are handled.

Depending on what you are trying to do, it might be right. But generally you want to handle this before a 404 handler is initiated because of performance.

So if this is part of your implementations 'way of working' everyday, you might want to solve it differently.

So put a few words on what you are trying to achieve, I might give you better pointers.
BR Nicolai

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Thank you for your answer, Nicolai.

I have taken over responsibility of a solution, where a custom redirect module has been implemented, to work after the direct paths. It doesn't work as intended though and your clarification supports my belief of how it works.

The customer would like the direct paths to have first priority, then the custom redirect module and then the builtin 404.

Would that approach be possible at all?

/Kurt 

 
Nicolai Pedersen
Reply

Please explain the scenario first... What are you trying to achieve (opposed to how you are trying to solve it...)

Thanks for clarifying.

BR Nicolai

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

The customer wants an easier way of doing a lot of redirects, instead of having to create them one by one as direct paths.

As mentioned earlier, they use a custom module which iterates through a csv-file, with paths for redirecting. The builtin direct paths should have highest priority though.

/Kurt

 

 
Nicolai Pedersen
Reply
This post has been marked as an answer

I have no good solution to that. It sounds wrong to handle a lot of redirects - something else must be wrong.

Anyways, an option is to import these custom ones into the urlpath table - or in the noticiation subscriber, check if a given path is handled by the direct path module:

Dim paths As PathCollection = Dynamicweb.Frontend.DirectPath.Path.GetPathsByUrl(Path)
If Not paths Is Nothing Then
                        Dim suitableAreas As IEnumerable(Of Area) = PageView.GetAreasByDomain()
                        p = If(paths.FirstOrDefault(Function(pa) suitableAreas.Any(Function(area) pa.AreaID = area.ID)), paths.FirstOrDefault())
End If

BR Nicolai

Votes for this answer: 1
 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

I agree, it is not a good way of handling this.

Thank you for your response. I will look into it and find a usefull solution.

/Kurt 

 

You must be logged in to post in the forum