Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I want to programatically create and save a new Template using an existing .cshtml file. When I call
var template = new Template(path, name, alias); _fileService.SaveTemplate(template);
the template is added to Umbraco, but the content of the template is missing!
A workaround that I can use is to copy the contents of the file before creating the template and then set it using the Content property:
var absPath = HttpContext.Current.Server.MapPath(Path.Combine("~", "Views", path)); var content = System.IO.File.ReadAllText(absPath); var template = new Template(path, name, alias) { Content = content };
But ideally I don't want to do that!
Any ideas?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Creating new Template clears content of file
I want to programatically create and save a new Template using an existing .cshtml file. When I call
the template is added to Umbraco, but the content of the template is missing!
A workaround that I can use is to copy the contents of the file before creating the template and then set it using the Content property:
But ideally I don't want to do that!
Any ideas?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.