SaaS CMS has officially launched! Learn more now.

Problem with own VPP

Vote:
 

We have an own Virtual Path Provider that shall fetch folders from an XML and files from a remote server based on an attribute on the folder.
Listing of the folders works fine, but when you go 2 steps down in the folder structure abd want's to go up episerver says "Unsaved page - A folder for this page isn't created..."
We can't find where the problem is, need assistance.

Directoris method in SampleDirectory.cs:

public override IEnumerable Directories
        {
            get
            {
                directoryXml = new XmlDocument();
                directoryXml.Load(HttpContext.Current.Server.MapPath("~/App_Data/FileStore/FileStore.xml"));

                if (this.IsFirstLevel)
                {
                    XmlNode startNode = directoryXml["filestore"];

                    _directories = new List<SampleDirectory>();
                    foreach (XmlNode folderNode in startNode.ChildNodes)
                    {
                        string virtualPath = VirtualPath + folderNode.Attributes["id"].Value + "/";
                        _directories.Add(new SampleDirectory(vpp, virtualPath));
                    }

                    return _directories;
                }
                else
                {
                    string[] folders = this.VirtualPath.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);

                    bool dirUpSelected = false;

                    string[] formKeys = HttpContext.Current.Request.Form.AllKeys[14].Split('$');
                    if (formKeys[formKeys.Length - 1] == "DirectoryUpButton")
                    {
                        folders = this.Parent.VirtualPath.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                        dirUpSelected = true;
                    }

                    string parentFolder = folders[folders.Length - 1];
                    XmlNode startNode = directoryXml["filestore"].SelectSingleNode("//folder[@id=\"" + (parentFolder ?? "") + "\"]");
                    if (startNode == null)
                        startNode = directoryXml["filestore"];

                    _directories = new List<SampleDirectory>();
                    foreach (XmlNode folderNode in startNode.ChildNodes)
                    {
                        string virtualPath = VirtualPath + folderNode.Attributes["id"].Value + "/";

                        if (dirUpSelected)
                            virtualPath = this.Parent.VirtualPath;

                        _directories.Add(new SampleDirectory(vpp, virtualPath));
                    }

                    return _directories;
                }
            }
        }

        public override string Name
        {
            get
            {
                XmlNode node = GetXmlNode(VirtualPath);
                if (node == null)
                {
                    return "";
                }
                XmlAttribute name = node.Attributes["name"];
                return name != null ? name.Value : base.Name;
            }
        }

        private XmlNode GetXmlNode(string virtualPath)
        {
            string[] folders = virtualPath.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);

            if (folders.Length == 0)
            {
                return null;
            }

            if (folders.Length == 1)
            {
                return directoryXml[folders[0]];
            }
            return directoryXml.SelectSingleNode(string.Format("//folder[@id='{0}']", folders[folders.Length - 1]));
        }

    

#53371
Sep 06, 2011 10:10
Vote:
 
#53372
Edited, Sep 06, 2011 10:14
Vote:
 

No ideas?

#54211
Oct 05, 2011 13:10
Vote:
 

Due to the number in the path it figures it is a page folder even though it is not ?

#54213
Oct 05, 2011 14:39
Vote:
 

Per, not following you, how do you mean?

#54214
Oct 05, 2011 14:42
Vote:
 

I cannot find a reference to the error message "Unsaved page - A folder for this page isn't created..." in our code, I am just guessing that it has something to do with page folders which are in the format of /folder/number.

#54215
Oct 05, 2011 15:26
Vote:
 

ok, but sorry to say that this info doesn't help us getting closer to solving our problem

#54216
Oct 05, 2011 15:36
Vote:
 

No, but maybe you can help me out here. Is there a reason I cannot find the error message for example, is it the actual error message or something like it ? And are the folders in this format or not ?

#54220
Edited, Oct 05, 2011 16:27
Vote:
 

Per, take a look at the link to the code, there is also a few screen shots displaying our problem.
The "folder" structure is loaded from a xml-file included in the codesample file.

#54229
Oct 06, 2011 7:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.