Embedded Resources

Wisej.NET recognizes embedded JavaScript files (.js), style sheet files (.css) and theme files (.theme and .mixin.theme).

You can use any embedded resource in your application and manage them as you would in any standard .NET application. This section covers the types and locations of resources that Wisej.NET detects and manages.

WisejResources Attribute

To use embedded resources in Wisej.NET, add the [assembly:WisejResources] attribute to your assembly in AssemblyInfo.cs.

The attribute takes two optional parameters:

  • A list of excluded resource names

  • The root name of resources when different from the default namespace

using Wisej.Core;

[assembly: WisejResources]
// or
[assembly: WisejResources(ExcludeList: "file1.js, file2.css")]
// or
[assembly: WisejResources(RootName: "MyApp.Resources.")]

Resources & Platform Folders

Only *.js and *.css files in these two folders are recognized by Wisej.NET and bundled in wisej.cs and wisej.css. To include a resource with [assembly:WisejResources] without bundling, place it in a different folder.

For VB.NET developers: The VB.NET compiler builds embedded resource names differently. It uses only the project's default namespace + file name, ignoring folder names. Resources in \Resources or \Platform won't be recognized when compiling with VB.NET.

To use these folders in VB.NET, rename your files like this:

  • \Resources\my-code-to-bundle.js\Resources\Resources.my-code-to-bundle.js

  • \Platform\my-code-to-bundle.js\Platform\Platform.my-code-to-bundle.js

Bundling and Minification

In release mode (debug flag off in Web.config), Wisej.NET automatically bundles and minifies all embedded .js and .css files from \Resources and \Platform.

JavaScript files are bundled in wisej.js. StyleSheet files are bundled in wisej.css.

Themes Folder

The \Themes folder has special handling:

  • Embedded themes/mixins in the main assembly load without [assembly:WisejResources]

  • Themes/mixins in other assemblies need [assembly:WisejResources] to load

  • Deployed theme files override embedded ones with the same name

Embedded Resource URL

Use embedded resources from any assembly by prefixing the path with resource.wx/, with or without [assembly:WisejResources].

Resource URLs work in HTML, CSS, JavaScript and Wisej.NET control ImageSource properties.

this.ImageSource = "resource.wx/image.png";
this.ImageSource = "resource.wx/MyAppAssembly/image.png";

You can use the assembly name (without .dll) or just the resource name in the path.

Without an assembly specified, Wisej.NET searches all loaded assemblies for the resource.

Allowed Resource Types

The resource.wx URL works only with these file types:

".css", ".js", ".html", ".jpg", ".png", ".gif", ".svg", ".bmp", ".jpeg"

Other file types return a 404 error.

Overriding Embedded Resources

Override embedded resources by placing a file with the same name in the deployed directory.

Examples:

  • resource.wx/button.png returns either:

    • button.png at application root

    • embedded button.png

  • resource.wx/CoolImages/button.png returns either:

    • button.png in \CoolImages folder

    • embedded button.png in CoolImages.dll

Last updated