Developer forum

Forum » Development » Redirect request on frontend causes error when saving visual editor on master site

Redirect request on frontend causes error when saving visual editor on master site

Mikkel Hammer
Mikkel Hammer
Reply

Hi DW,

We've found an issue that causes the Visual editor to "freeze" and not add the item correctly.
It happens when we try to add an item to the visual editor that has a field with the type "Item relation list" on a master page, at the same time as a redirect occurs on the same page in the frontend.

We have reproduced it on a fresh Swift 1.19 and DW 9.15.2.

On a fresh Swift create a "Blank page" on the master site -> add a shortcut to the same page on the danish language layer.


Remove the shortcut on the language layer to not end in endless loop :^)


Then go to the master site and open the visual editor on the page you created and add a row.
Then pull the "Accordion" into the row.


Then in the accordion, first add an random item with a title and content, it just used "tester" in both.
then before pressing "Ok" at the bottom, open another window and have the URL pasted in for the frontend of the master layer page you created, but dont go the url yet.
In the administration window with the visual editor open the developer window (usually F12 and go to the network tab so it records the request).

The in the browser with the frontend url pasted it, click it so you can navigate to it with "Enter", and then move your cursor to the "Ok" button in the visual editor.
When you're ready, press enter to start the frontend request in the other window and then immediately press "Ok" with your mouse in the visual editor, so it fires right after.



In the network tab, the request will fail with an null reference and the visual editor will spin with "Please wait" until you go to the Content area again.


It does add the item to the row event though the request failed.
But sometimes makes the row/item unable to be deleted for a few minutes, since it probably didn't get added correctly.


It a weird and specific scenario, but we have a solution where we redirect from the master site to the correct language layer for the customer, so it a common scenario on that solution, so the visual editor does this often. The same error happens when we redirect in the backend with Dynamicweb.Context.Current.Response.Redirect.

Hope you can help us out :)

Best regards,
Mikkel Hammer​


Replies

 
Mikkel Hammer
Mikkel Hammer
Reply

Any thoughts on this? It's a bit critical for our customer and it'd be great if we could get back to them with anything

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Only that steps to reproduce is crazy.

I think our solution to this is to remove the option to edit page you redirect to the same page on another language... Why would you even do this...?

I will have it bugged as 'not important' as you can easily work around it I guess - or do I misunderstand the problem?

BR Nicolai

 
Mikkel Hammer
Mikkel Hammer
Reply

This was only to show that the redirect logic is the issue and it can be reproduced on a clean solution.

We have a solution where our customer makes all the website changes on the master page of the site, so they don't have to do make the for each language layer.


But our "real" problem is that we've coded a redirect from master site to the best suited language layer based on customer IP location and other criterias.
So an example is when i go to https://www.evasolo.com/, it get redirected to https://www.evasolo.com/da based on my danish IP.
And in some of their campaigns they link to https://www.evasolo.com/products - where the customer then lands on the correct language productlist and so on, i guess you get the idea.

But since a lot of users enter those links - the redirects occurs often. And it makes it extremely difficult for our customer to make changes on the frontpage or productlist on the master page throughout the day, since it just freezes and spins forever.

So there is no direct redirect setup on the master pages, it happens in the backend when the page is loaded.


Best regards,
Mikkel Hammer

 
Mikkel Hammer
Mikkel Hammer
Reply

Here a snippet of the backend logic if it clears it up a bit further

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Ok - custom notification subscriber is important knowledge....

So if you remove this subscriber, you have no issues?

I can see you have great checks for visual editor mode, backend user etc. Good start.

I am not sure I understand what you want us to do? You run this code many many many times. 

I woudl recommend a couple of changes

  • PageTitle notification is relatively late in the page process - this means that a lot of content is generated before the redirect happens. Try moving this logic to BeforePreRequestHandlerExecute notification which is much earlier - and after the url has been resolved.
  • Store the lookup in session - and use that if present to redirect. That would save you a lot of lookups
  • Ensure you have no circular refs. You have try catch wrapper around all your code - including the redirect it self. You should avoid that - remove it completely or at least wrap the internals piece by piece and not the redirect - this could actually be a cause if you have circular stuff - and also redirect causes an exception to abort the thread.
  • Do not do new XxxService - use Dynamicweb.Content.Services.* and Dynamicweb.Ecommerce.Services.*

BR Nicolai

 
Mikkel Hammer
Mikkel Hammer
Reply

Hi Nicolai,

This was what i was trying to "avoid" by showing it can be reproduced in a clean installation with a "standard" redirect, i don't think it's our custom code that's causing the problem so to speak.
The problem is the redirect on the frontend, our visual editor request never hits the redirect logic.
But i'll try to implement your suggestions and see if it changes anything, so thanks for them :)

But i don't know if i've made it clear what the issue im trying to tell is. 
Sorry for the confusion, i'll try to make it clearer below.

It's a frontend request that is causing a totally separate visual editor request to fail. The two requests doesn't have to come from the same PC.
If you enter evasolo.com on your PC and trigger the redirect, at the same im trying to save the visual editor - my request on my PC fails with the error shown.
The two requests shouldn't have anything to do with eachother - doesn't that seem like a major issue?

Best regards,
Mikkel Hammer

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

QA has reproduced it - I do not understand it yet :-).

We have it under item Devops#12481

BR Nicolai

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply
This post has been marked as an answer

Hi Mikkel

The problem DevOps#12481 Redirect request on frontend causes error when saving visual editor on master site
Has now been fixed in Dynamicweb version 9.15.4 
Get this version from the download section https://doc.dynamicweb.dk/downloads/dynamicweb-9

Kind Regards
Care Support
Kristian Kirkholt

Votes for this answer: 1
 
Mikkel Hammer
Mikkel Hammer
Reply

Thanks a lot both :)

 

You must be logged in to post in the forum