Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Links get rewritten when site restarts

Vote:
 

Hi!

We have an issue with links to images that we've migrated from an EPiServer 6 site to an EPiServer 7 site. After the migrations script has run everything works fine. But if we restart the site the links get rewritten

Original link: "/Global/Test_bilder/logo_01.png"

Becomes this after restart: "~/link/d2b5ee7288f248beb8410effff75d7ec.jpg"


UrlRebasKind is set to "ToRootRelative", but that wouldn't affect links in this way would it?

This is the part of our migrations script that creates the files:

string testadress = "Global";
UnifiedDirectory destDir = HostingEnvironment.VirtualPathProvider.GetDirectory(testadress) as UnifiedDirectory;
string virtualPath = VirtualPathUtilityEx.Combine(destDir.VirtualPath, VirtualPathUtility.AppendTrailingSlash(Path.GetFileName(serverFile.Name)));

UnifiedFile file = HostingEnvironment.VirtualPathProvider.GetFile(virtualPath) as UnifiedFile;
if (file == null)
{
	file = destDir.CreateFile(Path.GetFileName(serverFile.Name));
}
else
{
	file.Delete();
	file = destDir.CreateFile(Path.GetFileName(serverFile.Name));
}
byte[] fileContent;
using (FileStream fileStream = new FileStream(serverFile.FullName, FileMode.Open, FileAccess.Read))
{
	fileContent = new byte[fileStream.Length];
	fileStream.Read(fileContent, 0, fileContent.Length);
}
using (Stream stream = file.Open(FileMode.Create, FileAccess.Write))
{
	stream.Write(fileContent, 0, fileContent.Length);
}

    

#79096
Dec 09, 2013 14:19
Vote:
 

Have you changed the types of vpp providers? Internally links of files in a versioningprovider vpp looks like "~/link....".  Nativeprovider is always relative.

#79098
Dec 09, 2013 15:06
Vote:
 

Both the old site and the new one we migrated to uses VirtualPathVersioningProvider. Files that are added after the migration does not seem to be affected though.

It's url properties that gets rewritten to the internal link for some reason.

#79102
Dec 09, 2013 15:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.