The most common Wisej applications (in the broad sense) have only a single application (in the strict sense). To keep things simple, we will use sub-application to refer to an application in the strict sense.
Wisej sub-applications are different entry points in your application, which are independent URL you can use for whatever purpose you decide. All Wisej projects must have at least one sub-application that is created by default.
When you create a new Wisej project, Wisej creates 3 startup files:
Default.html is used because that’s the filename we are used to, for a startup page in ASP.NET.
Program.cs is used because that’s where we look for the static (Shared in VB) Main method.
For simplicity, the .html and .json filenames should match, but they don't have to match.
You can rename Default.html and Default.json to anything. You can also use an .aspx file in case you need to run .NET code before the Wisej application is loaded, see Wisej.UserData for an example.
You can create a sub-application in the project's root or in a project's folder.
To create a sub-application, follow the steps:
- 1.Right click on the project (or a project's folder), selecting Add -> New Item.
- 2.On the Add New Item form, select Wisej on the left side and click on Application in the list.
- 3.Set the application Name and click Add.
Supposing you set the Name to Admin, Wisej creates 3 startup files, all with the same name:
The Admin.cs file is just like the Program.cs default file and looks like this:
static class Admin
/// The main entry point for the application.
static void Main()
Public Module Program
''' The main entry point for the application.
Public Sub Main()
We are trained to look for the .html file as the starting point for a web application. In fact, the Wisej sub-application starts by the .json file. Even when we type an URL that includes the .html part, Wisej looks for is the .json file. Later on, we will discuss the rules Wisej uses to get a .json file.
In the Admin sub-application we created, the Admin.json file looks like this:
"startup": "[ProjectName].Admin.Main, [ProjectName]"
This file tells Wisej two important pieces of information:
- What .html file to show on the browser - the "url" key.
- What startup method to run on the server - the "startup" key.
When the user types http://myApp.com/Admin, Wisej will find Admin.json, read the "url" key and load Admin.html and then invoke the startup method in Admin.json.
Browsers need an HTML-like file and Wisej needs the browser to load and execute wisej.wx. More on this later.
Instead of the startup method, we can specify the sub-application's main view. More on this below.
Wisej needs to know what method the server should execute on startup, in this case the method [ProjectName].Project.Main on assembly [ProjectName].
Say that instead of executing the Main method, we want to instantiate an AdminPage. In fact, most of the time, all the Main method does is instantiate a view (Form or Page). In this case, the Default.json file should look like:
"mainWindow": "[ProjectName].AdminPage, [ProjectName]"
Putting it all together, you will find the Wisej startup workflow quite simple. It's composed of the following steps:
- 1.Find a .json file.
- 2.Tell the browser to load and show the "url" HTML file.
- 3.Tell the server what to do, according to the key specified in the .json file:
- Execute the "startup" method or
- Instantiate (invoke the constructor of) the "mainWindow" view.
If you specify both, the "startup" and "mainWindow" properties, Wisej will execute both.
- 1.Replace the extension by .json If you type an URL that ends with an extension (html or any other extension), like http://myserver.com/Startup.php, if the file exists, Wisej tries to find the matching .json file (a file with the same name, but with the json extension instead of supplied extension). In this case it looks for \Startup.json. If Wisej is already loaded and cannot find a matching json file, the wisej.wx script reloads the same page.
- 2.Append Default.json to a folder path If you type an URL that refers to a folder, be it the root folder http://myserver.com or an URL that ends with "/" like http://myserver.com/Suppliers/, Wisej uses Default.json file at the specified folder location. In these cases, respectively at \Default.json and at \Suppliers\Default.json.
- 3.Append either .json extension or \Default.json If you type an URL that does NOT end with any extension like http://myserver.com/Customers, Wisej tries to find the .json file in two steps:
- Wisej appends .json to Customers and looks for \Customers.json.
- If \Customers.json doesn't exist, Wisej presumes Customers is a folder and appends \Default.json to the folder path. In this case, it looks for the .json file at \Customers\Default.json.
The Web.config file created by Wisej project templates, by default includes a section like this:
<add value="Default.html" />
According to rule 2) above, you don't need defaultDocument to be defined in the Web.config file.
If the URL is the web site URL, it refers to a folder and Wisej looks for the .json file at the project's root folder, it looks for \Default.json.