Developer forum

Forum » Development » Area copy issue

Area copy issue

Jonas Mersholm
Reply

Hi.

I'm using the following to copy an Area

Dynamicweb.Content.Area A  = Ase.Copy(Dynamicweb.Content.Area.CopyMode.StructureAndContent, false, true, true, true, false);    

I'm then changing a few settings like domain, domainlock etc. And saving

A.Save();

 

All this from an ASHX file. 

Now, the problem arises when trying to fetch the ASHX because the Area Save function outputs

<script>parent.updateStatus("Copying pages...");</script>
<script>parent.updateStatus("Copying page 15 of 15 (100%)...");</script>
<script>parent.updateStatus("Updating links...");</script>
<script>parent.updateStatus("Copying content...");</script>
<script>parent.updateStatus("Copying content: 15%...");</script>
<script>parent.updateStatus("Updating global references...");</script>
<script>parent.updateStatus("Done copying. Updating cache...");</script>

This means that my json response, which im outputting, is not formatted correctly, since its prepended to the output.

 

At the same time, the Area is actually not available before i log into my backend, select the website from the website list, and clicks "save" button. How can this be?

 

Im hoping for help

Thank you

 

Jonas


Replies

 
Jonas Mersholm
Reply

bump

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Jonas,

This is indeed an issue.

Though it's the Copy method that hijacks the Response and not the Save, I don't see a way for you to solve this unless you start manipulating output stream of the HttpContext.Current.Response object -- unless you can avoid the Copy method altogether.

I've added a backlog item to get this fixed. Which version of Dynamicweb are you using?

- Jeppe

Votes for this answer: 1
 
Jonas Mersholm
Reply

Hi Jeppe, thank you for the answer.

The specific client is using V.8.4.1.12

 

Do you by any chance, have the time to answer http://developer.dynamicweb.com/forum/development/variantgroup-not-being-added-to-product.aspx aswell?

 

Thanks in advance.

Jonas

 
Jonas Mersholm
Reply

Thank you Jeppe, so far.

Is it possible for you to answer my second question in this thread? Whenever i save the area from c#, it's not actually active before i log onto the DW backend, opens the website and clicks "save"

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

What is the value of the Active property of the new copy?

 
Jonas Mersholm
Reply

Hi Jeppe,

 

The active property is set to True.

 

Best regards.

Jonas

 
Jonas Mersholm
Reply

Solved the HttpContext.Current.Response hijack by making a custom Stream filter for the given request.

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

I have answered your other thread regarding area not being available: http://developer.dynamicweb.com/forum/development/development/area-not-persisting-correctly.aspx

 
Martin Nielsen
Reply

Hi Jonas and Jeppe,

I'm building a very similar function, but i have a problem when i execute the area.copy() method.

I have a function like this:

    private int CopyArea( int sourceAreaId, string newAreaName )
    {
      Dynamicweb.Content.Area sourceArea = Dynamicweb.Content.Area.GetAreaById( sourceAreaId );
      Dynamicweb.Content.Area newArea = sourceArea.Copy( Dynamicweb.Content.Area.CopyMode.StructureAndContent, true, true, true, true, false );
      newArea.Name = newAreaName;
      newArea.Description = string.Concat( "Copy of '", sourceArea.Name, "'" );
      newArea.Active = true;
      newArea.Save();

      return newArea.ID;
    }

And i've tried to execute this method from an ASHX handler and from a PageLoaded subscriber, but i never get past the copy method.

In an ASHX handler i get:

Object reference not set to an instance of an object.
Line 47: Dynamicweb.Content.Area newArea = sourceArea.Copy( Dynamicweb.Content.Area.CopyMode.StructureAndContent, true, true, true, true, false );

 

On a page i get an infinite loop because once .copy() is hit, the page reloads, and my code notification is run again and again and again.

How did you handle this Jonas? Jeppe?

 

// Martin

 
Nicolai Høeg Pedersen
Reply

This, by the way, will be fixed in 8.6.

But how it was solved, Jonas knows?

Nicolai

 

You must be logged in to post in the forum