Try our conversational search powered by Generative AI!

Links get rewritten when site restarts



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));
	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);


Dec 09, 2013 14:19

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

Dec 09, 2013 15:06

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.

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.