Wisej.NET Deployment
HomeNewsSupportVideos
  • Deployment
  • Targets
    • IIS
    • NGINX
    • Apache
    • Self Hosted
    • Hybrid
    • Amazon AWS
    • Microsoft Azure
    • ASP.NET Hosting
    • Linux, MacOS
    • Desktop (deprecated)
  • Concepts
    • Load Balancing
    • Visual Studio Publishing
    • Server Debugging
  • Troubleshooting
    • License Activation
Powered by GitBook
On this page
  • .NET Core
  • Basic Steps
  • Service
  • Security
  • .NET Framework
  • Basic Steps
  • Service
  • Process
  • Web.Config Classic

Was this helpful?

Export as PDF
  1. Targets

Self Hosted

How to run a Wisej app as a self-hosted process or service.

PreviousApacheNextHybrid

Last updated 3 months ago

Was this helpful?

.NET Core

Wisej 3 .NET Core applications are self-hosted by default being standard ASP.NET Core applications. ASP.NET Core apps are built to an executable that you can simply start and will start hosting your application. You don't need to use Wisej.HostService.exe.

If you are deploying on a distribution or on , make sure is installed.

Starting with Wisej.NET 4, the use of libgdiplus is no longer necessary. This change is due to the development of a new managed System.Drawing library, which has been created in conjunction with .

Basic Steps

  1. Run the to deploy to a folder.

Service

  1. Add builder.Host.UseWindowsServices() to Startup.cs or Startup.vb (see code snippet below).

  2. Now you can start the service like any other Windows service. For any additional configuration option refer to the Microsoft documentation.

var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
  Args = args,
  WebRootPath = "./",

    // Add this:
  ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default
});

// And this
builder.Host.UseWindowsService();

...
' Add UseWindowsService() and UseContentRoot like shown below
Host.CreateDefaultBuilder(args).UseWindowsService().ConfigureWebHostDefaults(
    Sub(builder)
        builder.UseWebRoot("./")
        builder.UseStartup(Of Startup)()
        builder.UseContentRoot(If(WindowsServiceHelpers.IsWindowsService(), AppContext.BaseDirectory, Nothing))
    End Sub).Build().Run()

Security

When deploying on .NET Core, you are unable to use the web.config file to configure the System.Web.HttpForbiddenHandler, which is typically used to block the downloading of potentially sensitive .json files. As a result, these .json files could become accessible for downloading, which might pose a security vulnerability.

Since ASP.NET Core relies on middleware modules instead of using traditional HttpHandlers and HttpModules, to secure specific files or directories, you need to modify the configuration in the Startup.cs file. Adjusting the middleware settings within Startup.cs allows you to implement security measures to protect sensitive files or directories effectively.

Below is an example of how to block access to specific files or directories in ASP.NET Core, based on your security requirements. You can customize the middleware configuration in the Startup.cs file to meet your particular security needs.

Conditional UseFileServer
// app.UseFileServer();
app.UseWhen(
 cx => !cx.Request.Path.Value.EndsWith(".json", StringComparison.OrdinalIgnoreCase), 
 app => app.UseFileServer()
);

.NET Framework

Basic Steps

  1. Create the application directory

  2. Copy Wisej.HostService.exe to the application directory

  3. Create the /bin directory in the application's directory

  4. Copy all the assemblies from your local /bin to the server's /bin (no need to copy xml and pdb files)

  5. Copy the /Themes folder if you have custom themes or mixins

  6. Copy the /Images folder if you have images that need to be served as URLs

  7. Copy the /App_Data folder if your application uses it

  8. Copy Default.html (and other html files you use sub-applications)

  9. Copy Default.json (and other json configuration files if you use sub-applications)

  10. Copy favicon.ico.

Wisej.HostService is currently only available in GitHub - you need to download the source code and compile the executable.

Once the deployment directory is ready, you can either register Wisej.HostService.exe as a Windows service, or run it directly as a normal process.

These are the supported startup arguments:

(none) or -start

Starts the host process for the current Wisej application: where the process is located.

-stop

Stops the process for the current Wisej application

-p:{port} or -port:{port}

Changes the port. The default is 8080.

-d:{domain name} or -domain:{domain name}

Limits the domain: i.e. * = all, or localhost to accept local connections only. The default is *.

-i or -install

Installs Wisej.HostService as a Windows service for the current Wisej application.

-u or -uninstall

Uninstalls Wisej.HostService from the Windows services.

-n:{name} or -name:{name}

Changes the name of the service, otherwise Wisej sets the name to “Wisej.HostService: “ + {Name of Wisej Application Folder}

Listening on port 80 may be restricted by the OS unless the process is started as Administrator.

Service

Register the executable to run as a service:

>Wisej.HostService -i -p:8181

You can start the same service multiple times listening on different ports.

>Wisej.HostService -i -p:8181
>Wisej.HostService -i -p:8182
>Wisej.HostService -i -p:8183

Used in conjunction with a load balancer like NGINX, you can have multiple processes of the same application handle their share of the sessions.

Process

Run Wisej.HostService.exe as any other process. You can configure Windows to start the process at startup or use Windows Task Scheduler or any other means to start the process.

>Wisej.HostService -d:localhost

Starts the process listening for connections to localhost on port 8080 (the default).

Web.Config Classic

If your web.config file doesn't include the <system.web> section (classic pipeline), add it as shown in the example below. All it needs is the definition of the Wisej httpModule. under <system.web> and to turn the validation of the integrated mode in <system.webServer>, otherwise IIS will throw in an error.

<configuration>
...
  <system.web>
    <compilation debug="false" />
    <httpRuntime targetFramework="4.8" maxRequestLength="1048576"/>
    <httpModules>
      <add name="Wisej" type="Wisej.Core.HttpModule, Wisej.Framework"/>
    </httpModules>
  </system.web>
...
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
...

Once the web.config file includes these settings it can be used with IIS, self hosting, standalone, and Ultidev/Cassini deployments.

That's it. When you run YourApplication.exe you can use the --urls command line argument to .

Wisej 3 ASP.NET Core apps can be deployed as a quite easily:

Add the nuget to your project.

Register the service using ""

You can run a Wisej application (including Wisej 3 on .NET 4.8) as a self hosting process or service. All you need to do is deploy the executable in the root folder of the deployment directory.

Copy

Self Hosting uses the classic pipeline instead of the integrated pipeline in web.config. If the classic configuration is not already present in your web.config, you need to add it. See the section below to see what to add.

configure the application's endpoints
Windows service
WindowsServices
sc create
Wisej.HostService
Web.config
web.config
👉
Linux
MacOS
libgdiplus
ImageSharp
publishing tool