Wisej.NET
Ask or search…
K

Embedded Resources

Wisej 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 is about the type and location of resources that are detected and managed by Wisej.

WisejResources Attribute

To use the embedded resources feature of Wisej, you need to add the [assembly:WisejResources] attribute to your assembly in AssemblyInfo.cs.
The attributes takes two optional parameters to let you specify a list of excluded resource names and the root name of the resources when it's 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
Only *.js and *.css files in these two folders are recognized by Wisej and bundled in wisej.cs and wisej.css. If you want to bundle a resource in your application with the [assembly:WisejResources] and NOT bundle it, place it in a different folder.
For VB.NET developers: The VB.NET compiler doesn't use the folder names to build the embedded resource name. It only uses the default namespace of the project + the file name. Even if you place your embedded resources in \Resources or \Platform they will not be recognized by Wisej when compiling using VB.NET.
You can still place your embedded resources in \Resources or \Platform in VB.NET, but you also have to rename the file 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
When running in release mode (the debug flag is off in Web.config) Wisej automatically bundles and minifies all embedded .js and .css files found in \Resources and \Platform.
JavaScript (.js) files are bundled in wisej.js. StyleSheet (.css) files are bundled in wisej.css.

Themes Folder

The \Themes folder is treated differently:
  • Embedded themes and mixins (.theme, .mixin.theme) in the application's main assembly are loaded also without the [assembly:WisejResources] attribute.
  • Embedded themes and mixins in other assemblies are loaded only when the [assembly:WisejResources] attribute is present.
  • Any theme file in a deployed \Theme folder override the embedded theme file with the same name. This feature lets you override a theme without having to recompile the assembly.

Embedded Resource URL

You can use any embedded resource in any assembly in your project with or without the [assembly:WisejResources] attribute by prefixing the path to the resource with resource.wx/.
The resource URL can be used anywhere: in HTML, in CSS, in JavaScript and in any of the ImageSource properties exposed by Wisej controls.
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 fully qualify the path to the resource using the name of the assembly (without .dll) or you can use only the name of the resource.
When the URL doesn't specify the assembly, Wisej will look for a resource matching the name in all loaded assemblies.
Allowed Resource Types
Requesting a resource using the resource.wx URL is allowed only for these file types:
".css", ".js", ".html", ".jpg", ".png", ".gif", ".svg", ".bmp", ".jpeg"
Requests for non allowed file types return a 404 error.
Overriding Embedded Resources
You can override embedded resources by replacing it with a file with the same name in the deployed directory - the file name and path must match.
For example, a request for resource.wx/button.png will return the file button.png at the root of the application, or the embedded button.png.
For example, a request for resource.wx/CoolImages/button.png will return the file button.png in the \CoolImages folder or the embedded button.png in the CoolImages.dll assembly.