Application
Wisej.Web.Application
Namespace: Wisej.Web
Assembly: Wisej.Framework (3.5.0.0)
Represent a Wisej application session. Provides methods and events to manage the application in the context of the current session.
This class provides several static methods, properties and events that allow the application to manage all sorts of features related to the current session:
Save and retrieve session variable. Use Session to store and retrieve session variable. The property is a dynamic object and a Dictionary, therefore you can access its properties directly or through the indexer.
Manage cookies. Use Cookies to manage browser's cookies.
Read server variables. Use ServerVariables to retrieve all the data made available by the server. Some of the variables in the collection are also available directly: ServerPort, ServerName, UserAgent, etc.
Read the application's URL. Use Uri, Url, StartupUri, and StartupUrl.
Read the application's system information. Use StartupPath, ProductName, ProductVersion, etc.
Listen to the application's global events. See SessionTimeout , BeginRequest, ApplicationStart, ApplicationExitApplicationRefresh, BrowserSizeChangedResponsiveProfileChanged, CultureChanged, and many more.
Manage all live components in the session. Through the Application class you can find, iterate, inspect all live components of any type. See OpenForms for all the currently created (visible or invisible) instances of Form. OpenPages returns all the created Page objects. FindComponent and FindComponents provide an easy way to find any component in the session or to iterate the list of components that match a custom expression.
Start background tasks in context. StartTask provides a powerful way to start a background task on the server that can keep interacting with the client browser while running independently.
Manage the application's theme. Use LoadTheme to load a Wisej theme into the application. Or use the Theme object to read all sorts of information from the current ClientTheme.
Terminate the application without waiting for the session to timeout. Use Exit to terminate the current session and free all the related memory.
There is a lot more exposed by the Application class. You can inspect all the properties and methods in Visual Studio through IntelliSense or online at docs.wisej.
Properties
ClientProfile: Returns or sets the current client responsive profile.
This is the profile that best matches the current browser on the client. It is updated automatically on every request.
ClientBrowser: Returns or the client browser's information.
X509Certificate2: EXPERIMENTAL: Provides the client certificate fields issued by the client in response to the server's request for the client's identity. Since 3.5.6
String: Returns the current unique client id.
ClientCollection: Returns a collection of all the unique client browsers using the application.
CommandManager: Returns the current CommandManager.
String: Returns the path for the application data that is shared among all users.
RegistryKey: Returns the registry key for the application data that is shared among all users.
String: Returns the company name associated with the application stored in the AssemblyCompanyAttribute.
Configuration: Returns the current Configuration.
CookieCollection: Collection of cookies.
IWisejComponent: Returns the application component instance that an application can store and use later to restore the context when updating client widgets during an out-of-bound call using the Update method.
Threads that are not started using StartTask don't have any knowledge of the current session and don't have a way to communicate with the client The Current property returns the instance of the Application class that is bound to the current session. It can be used just like any other component with the method Update or RunInContext to restore the session for the current thread. The advantage of using Current instead of the instance of a control or a page is to avoid to keep a reference to a component that may be disposed by the application.
CultureInfo: Returns or sets the current CultureInfo for the session.
Desktop: Returns or sets the current Desktop.
Boolean: Returns or sets whether the browser will ask the user to confirm unloading the current page.
This property attaches the window.onbeforeunload event. See https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload. It's not possible to determine whether the page is being unloaded because the user is trying to close the tab, close the browser, or is refreshing the page, or is taking any other action that may reload the page.
String: Returns the path for the application's main assembly.
Image: Returns or sets the favicon to display in the browser.
String: Returns or sets the URL to the favicon to display in the browser.
String: Returns or sets the hash part of the URL on the client.
Boolean: Returns a value indicating whether the session has been authenticated.
Boolean: Indicates that the current application instance, which corresponds to the session, has been terminated and disposed.
Boolean: Returns true when the current session has expired.
Boolean: Returns true if this session is running in secure mode (https:// and wss://)
Boolean: Returns true when the current session has been terminated.
Boolean: Returns true if the current session is connected using WebSocket.
Object: Returns a dynamic object containing the currently loaded license information. Since 3.1.3
These are the currently available fields (may change in future releases):
Valid: Whether the license is valid. Note that a license may be expired and valid if the product release date is within the license expiration date.
LicenseKey: License key loaded from web.config or assigned to LicenseKey.
ProductName: Full name of the licensed product.
CustomerName: Name of the registered customer that owns the license.
ExpirationDate: Expiration date for the product free updates.
Retrieve the values either using a dynamic object or a property indexer:
String: Returns or sets the runtime server license key.
Setting the LicenseKey programmatically has to be done before the application is loaded. The best place is the static constructor for the Program static class, or the static constructor of the main window (if defined in Default.js).
Page: Returns or sets the current full page window.
FormCollection: Returns a collection of open forms owned by the application.
PageCollection: Returns a collection of open pages owned by the application.
ClientPlatform: The name of the currently loaded platform.
String: Returns the product name associated with this application.
String: Returns the product version associated with this application stored either in AssemblyInformationalVersionAttribute or AssemblyFileVersionAttribute.
NameValueCollection: Returns the parameters used to launch the application.
Boolean: Returns or sets whether all the controls in the applications should operate using the right-to-left mode.
The value of this property is updated automatically when the current language changes if the value of "rightToLeft" in the application configuration file is set to "auto".
Boolean: Returns true when the application is running in not in design, debug or test mode.
String: Returns the server's host name, DNS alias, or IP address as it would appear in self-referencing URLs.
Int32: Returns the port number to which the request was sent.
NameValueCollection: Returns the server variables.
ServiceProvider: Returns the ServiceProvider implementation used by Wisej.NET to manage Dependency Injection across the application. Since 3.1
Object: Provides a generic storage for session-based objects.
Int32: Returns the total number of currently active sessions.
String: Returns the unique current session ID.
Boolean: Shows or hides the debug console on the browser.
Displays a simple HTMl only debug console. Works with any browser also when the developer tools are not available.
Boolean: Returns or sets whether the browser is blocked by the Ajax loader.
String: Returns the root path of the web application.
Uri: Returns the URI used to start the application.
String: Returns the URL used to start the application.
ClientTheme: Returns or sets the current ClientTheme.
You can create and modify a new custom theme using the ClientTheme class. The new theme can be based on an existing theme, can be empty, or can be initialized from a JSON string.
You may also alter a global theme shared by all sessions.
String: Returns or sets the page title in the browser.
Uri: Returns the current Uri used either to launch or reload the application. It may be different from StartupUri.
String: Returns the current URL used either to launch or reload the application. It may be different from StartupUrl.
IPrincipal: Returns the security information for the current request.
String: Returns the raw user agent string of the client browser.
String: Returns the IP host address of the remote client.
String: Returns the DNS name of the remote client.
WindowsIdentity: Returns the WindowsIdentity type for the current user.
String[]: Gets a sorted string array of client language preferences.
Methods
Adds an event filter to monitor all the incoming events before they are routed to their respective component.
filter
Adds the text and corresponding translation to the default locale on the client.
text
The text to translate.
translation
The translation override.
Instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
message
A string you want to display in the alert dialog.
Returns: Task. An awaitable Task that represents the asynchronous operation.
Executes the JavaScript function on the client.
function
The name of the function to execute.
args
The arguments to pass to the function.
Executes the JavaScript function on the client and receives the return value (or null) in the callback method.
function
The name of the function to execute.
callback
Asynchronous callback method that receives the return value.
args
The arguments to pass to the function.
Asynchronously executes the JavaScript function on the client and returns an awaitable Task with the result of the remote call.
function
The name of the function to execute.
args
The arguments to pass to the function.
Returns: Task<Object>. An awaitable Task that represents the asynchronous operation.
Cancels the fullscreen mode.
Instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels the dialog. until the user dismisses the dialog.
message
A string you want to display in the confirm dialog.
Returns: Task<Boolean>. An awaitable Task that represents the asynchronous operation.
Downloads the specified file on the client.
filePath
The file to download.
The name of the file to save on the client.
Optional callback invoked when fileName is downloaded.
Downloads the specified image to the client.
image
The image to download.
fileName
The name of the file to save on the client.
Optional callback invoked when fileName is downloaded.
Downloads the bytes in the stream to the client.
stream
The stream to send to the client.
fileName
The file name the client will use to save the stream.
Optional callback invoked when fileName is downloaded.
Downloads the specified file on the client.
target
Specifies where to open the file. Leave empty or use "_self" to open in the current tab, _blank to open in a new tab.
filePath
The file to download.