Using a layout file with embedded resources
See original GitHub issueHi. Thanks for this great project. It makes send nicely formatted emails so much easier.
Using the file system engine, I can include something like this in one of my templates
@{
Layout = "_Layout";
}
I don’t want to relay the file system in prod so I’m looking at changing the engine to use embedded resources, however this results in an exception of Project can not find template with key _Layout.cshtml
. Both files are embedded. Am I missing something here? I didn’t see much in the way of docs for layout files.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
c# - How can we add embedded resources to a file which ...
1 Answer. You'll need to create a . resources file containing the files you want to embed as resources, and then reference the...
Read more >Reuse layouts with <include>
To efficiently reuse complete layouts, use the <include> and <merge> tags to embed one layout inside another.
Read more >Embedded resources and Layout pages — MvcCodeRouting
I have created a MVC site that uses MvcCodeRouting to register routes for 2 'modules' - which are MVC sites where the content...
Read more >Create resource files - .NET
Create a binary resource (.resources) file programmatically. You can then embed the file in an application executable or an application library ...
Read more >ASP.NET Core (.csproj) Embedded Resources
I've previously blogged about how to have embedded resources in ASP. ... I figured I would show how the project.json translates to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For your embedded resource project, the key for _Layout.cshtml would be “EmailTemplates._Layout.cshtml”. So in NotificationDigest.cshtml, you would set the layout like this:
If all your templates are within
EmailTemplates/
, and you don’t want to have to include “EmailTemplates” in the key, you can set the root namespace by doing something like this:.UseEmbeddedResourcesProject(typeof(Test).Assembly, "RazorLitePoc.Services.EmailTemplates")
Also see #378
In case other people come here wondering why this isn’t working, note that there’s a DOT between the folder name (“EmailTemplates”) and the layout name (“_Layout.cshtml”), and not a SLASH.