Embedded Resources
Wisej.NET recognizes embedded JavaScript files (.js), style sheet files (.css) and theme files (.theme and .mixin.theme).
You can use and manage embedded resources as you would in any standard .NET application. This section explains which resource types and locations Wisej.NET detects and manages automatically.
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
- C#
- VB.NET
using Wisej.Core;
[assembly: WisejResources]
// or
[assembly: WisejResources(ExcludeList: "file1.js, file2.css")]
// or
[assembly: WisejResources(RootName: "MyApp.Resources.")]
<Assembly: Wisej.Core.WisejResources()>
' or
<Assembly: Wisej.Core.WisejResources("file1.js, file2.css")>
' or
<Assembly: Wisej.Core.WisejResources("", "MyApp.Resources.")>
Resources & Platform Folders
Wisej.NET automatically bundles embedded *.js and *.css files from the Resources and Platform folders into wisej.js and wisej.css, respectively. To include a resource with [assembly:WisejResources] without bundling it, 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 into wisej.js, and style sheets are bundled into 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.
- C#
- VB.NET
- CSS
this.ImageSource = "resource.wx/image.png";
this.ImageSource = "resource.wx/MyAppAssembly/image.png";
Me.ImageSource = "resource.wx/image.png"
Me.ImageSource = "resource.wx/MyAppAssembly/image.png"
.someClass
{
background-image: url('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.pngreturns either:button.pngat application root- embedded
button.png
resource.wx/CoolImages/button.pngreturns either:button.pngin\CoolImagesfolder- embedded
button.pnginCoolImages.dll