Skip to content

For use by Umbraco package developers to serve embedded resources.

License

Notifications You must be signed in to change notification settings

Hendy/umbraco-embedded-resource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Umbraco Embedded Resource

For use by Umbraco package developers to serve embedded resources.

The NuGet package installs a single assembly Our.Umbraco.EmbeddedResource.dll.

Using embedded resources within an assembly for a package has some of advantages:

  1. No need to split a package into two NuGet packages to prevent \App_Plugins*.* files from added into a class library project.

  2. There's nothing to add into source control (other than a NuGet reference) for the end consumer.

  3. Resources can be protected so that they are only served to back office authenticated users (no leakage as to what packages are installed).

Usage

The embedded resources in your project need to be registered and this is done via assembly attributes (typically placed in /Properties/AssemblyInfo.cs).

There are two assembly attributes:

Both attributes have the same two required parameters:

  • The full namespace path to the embedded resource
  • The app relative url that the resource should be served on

Example

@using Our.Umbraco.EmbeddedResource

// register an embedded jpg as if it were on the file system    
[assembly: EmbeddedResource("MyPackage.Example.jpg", "/App_Plugins/MyPackage/Example.jpg")]

// register an embedded png, served only to back office users    
[assembly: EmbeddedResourceProtected("MyPackage.Example.png", "/App_Plugins/MyPackage/Example.png")]

About

For use by Umbraco package developers to serve embedded resources.

Resources

License

Stars

Watchers

Forks

Packages

No packages published