Web - Nano-Core/Nano.Library GitHub Wiki

Table of Contents


Summary

The WebApplication derives from DefaultApplication.
As the names states, the implementation is for web based applications.

Sample implementation
public class Program
{
    public static void Main()
    {
        WebApplication
            .ConfigureApp()
            .ConfigureServices(x =>
            {
                // Additional dependencies...
            })
            .Build()
            .Run();
    }
}

Configuration

The Web section of the configuration defines behavior related to the application. The section is deserialized into an instance of WebOptions, and injected as dependency during startup, thus available for injection throughout the application.

See Appendix - App Settings for details about the web section and the meaning of the variables.

Web Section
  "Web": {
    "Hosting": {
        "Root": "api",
        "Ports": [
        ],
        "PortsHttps": [
        ],
        "ShutdownTimeout": 10,
        "UseHttpsRequired": false,
        "UseForwardedHeaders": true, 
        "UseResponseCompression": true, 
        "UseContentTypeOptions": false, 
        "ExposeErrors": false,
        "ExposeAuditController": true, 
        "ExposeAuthController": true, 
        "Hsts": {
            "IsEnabled": false, 
            "MaxAge": null,
            "UsePreload": false,
            "IncludeSubdomains": false 
        },
        "Csp": {
          "BlockAllMixedContent": false,
          "UpgradeInsecureRequests": false,
          "Defaults": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Styles": {
            "IsNone": false,
            "IsSelf": false,
            "IsUnsafeInline": false,
            "Sources": [
            ]
          },
          "Scripts": {
            "IsNone": false,
            "IsSelf": false,
            "IsUnsafeEval": false,
            "IsUnsafeInline": false,
            "StrictDynamic": false,
            "Sources": [
            ]
          },
          "Objects": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Images": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Media": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Frames": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "FrameAncestors": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Fonts": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Connections": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "BaseUris": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Children": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Forms": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Manifests": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Workers": {
            "IsNone": false,
            "IsSelf": false,
            "Sources": [
            ]
          },
          "Sandbox": {
            "AllowForms": false,
            "AllowModals": false,
            "AllowOrientationLock": false,
            "AllowPointerLock": false,
            "AllowPopups": false,
            "AllowPopupsToEscapeSandbox": false,
            "AllowPresentation": false,
            "AllowSameOrigin": false,
            "AllowScripts": false,
            "AllowTopNavigation": false
          },
          "PermissionsPolicy": {
            "Accelerometer": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "AmbientLightSensor": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "AutoPlay": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Battery": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Camera": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "DisplayCapture": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "DocumentDomain": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "EncryptedMedia": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "ExecutionWhileNotRendered": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "ExecutionWhileOutOfViewport": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "FullScreen": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Gamepad": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Geolocation": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Gyroscope": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "LayoutAnimations": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "LegacyImageFormats": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Magnetometer": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Microphone": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Midi": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "NavigationOverride": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "OversizedImages": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Payment": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "PictureInPicture": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "PublicKeyCredentialsGet": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "SpeakerSelection": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "SyncXhr": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "UnoptimizedImages": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "UnsizedMedia": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "Usb": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "ScreenWakeLock": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "WebShare": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            },
            "XrSpatialTracking": {
              "IsNone": false,
              "IsSelf": false,
              "Sources": [
              ]
            }
          },
          "ReportUris": [
          ],
          "PluginTypes": [
          ]
        },
        "Cors": {
          "AllowedOrigins": [
          ],
          "AllowedHeaders": [
          ],
          "AllowedMethods": [
          ],
          "AllowCredentials": true,
          "Origin": {
            "EmbedderPolicy": null,
            "OpenerPolicy": null,
            "ResourcePolicy": null
          }
        },
        "Cache": {
            "IsEnabled": true, 
            "MaxSize": 1024,
            "MaxBodySize": 102400,
            "MaxAge": "00:20:00"
        },
        "Robots": {
            "IsEnabled": false, 
            "UseNoIndex": false,
            "UseNoFollow": false,
            "UseNoSnippet": false,
            "UseNoArchive": false,
            "UseNoOdp": false,
            "UseNoTranslate": false,
            "UseNoImageIndex": false
        },
        "Session": {
            "IsEnabled": true, 
            "Timeout": "00:20:00"
        },
        "HealthCheck": {
          "UseHealthCheck": true,
          "UseHealthCheckUI": true,
          "EvaluationInterval": 10,
          "FailureNotificationInterval": 60,
          "MaximumHistoryEntriesPerEndpoint": 50,
          "WebHooks": [
            {
              "Name": null,
              "Url": null,
              "Payload": null
            }
          ] 
        },
        "Certificate": {
            "Path": null,
            "Password": null
        },
        "VirusScan": {
            "IsEnabled": false,
            "Host": "clamav",
            "Port": "3310",
            "UseHealthCheck": true
        },
        "ReferrerPolicyHeader": "Disabled",
        "FrameOptionsPolicyHeader": "Disabled",
        "XssProtectionPolicyHeader": "Disabled"
    },
    "Documentation": {
        "IsEnabled": true,
        "CspNonce": null,
        "UseDefaultVersion": true,
        "Contact": {
            "Name": null,
            "Email": null,
            "Url": null
        },
        "License": {
            "Name": null,
            "Url": null
        }
    }
}

Injected Services

When building the WebHost, dependencies related to hosting is configured and initialized. This evolves around defining the process and environment in which the application is executing in.

Dependencies:
  • Nano.Web.WebOptions
  • Nano.Web.WebApplication
  • Nano.Web.Middleware.Hosting.ExceptionHandlingMiddleware
  • Nano.Web.Middleware.Hosting.HttpRequestIdentifierMiddleware
  • Nano.Web.Middleware.Hosting.HttpRequestUserMiddleware

For a full list of services and dependencies, see Injected Dependencies