System Library Common Framework
Search Results for

    *.Benchmark*,*.Tests*,*.ApiTests*,*.BaseTest*,DelegateJsonConverter,CalleeCancelledRequestException,ClientResponse,ContentType,OutputCachePolicy
    Show / Hide Table of Contents Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Framework SystemLibrary.Common.Framework.App.dll

    Framework service and middelware options

    FrameworkOptions

    public class FrameworkOptions

    Inheritance
    object
    FrameworkOptions
    Examples
    X

    Inside your startup.cs/program.cs...

    FrameworkOptions Options = new FrameworkOptions { };
    
    public class CustomViewLocations : IViewLocationExpander
    {
        //...implement the interface
        public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
        {
            return new string[] {   
                "~/Folder2/{0}/Index.cshtml"
            }
        }
    }
    
    public void ConfigureServices(IServiceCollection services)
    {
        Options.UseMvc = false;
        // Options.ViewLocationExpander = new CustomViewLocations();
        Options.ViewLocations = new string[] {
            "~/Folder/{0}/Index.cshtml",
            "~/Folder/{1}/{0}.cshtml"
        }
        app.AddFrameworkServices(Options);
    }
    
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        Options.UseHttpsRedirection = false;
    
        app.UseFrameworkMiddlewares(Options);
    }
    Arguments
    X

    Fields

    Optional: Additional endpoint configuration registered after RazorPages, Controllers, and ApiControllers, but before response compression middleware

    public Action<IEndpointRouteBuilder> AfterDefaultEndpoints

    X
    Field Value
    Type Description
    Action<IEndpointRouteBuilder>

    Add multiple assemblies as a 'part' so controllers within the assemblies are tried matched against requests

    public Assembly[] ApplicationParts

    X
    Field Value
    Type Description
    Assembly[]

    Pass in a string array of area view location formats

    Example:

    AreaViewLocations = new string[] { "~/Area/{2}/{1}/{0}.cshtml" };
    Remarks
    X

    This sets area view locations

    public string[] AreaViewLocations

    X

    Simple example:

    var options = new FrameworkOptions();
    options.ViewLocations = new string[] { "~/Pages/{2}/{1}/{0}.cshtml" }
    X
    Field Value
    Type Description
    string[]

    Optional: dditional endpoint configuration registered before RazorPages, Controllers and ApiControllers

    Remarks
    X

    These endpoints will be called after StaticFiles, Routing, CookiePolicy, OutputCache, Authentication and Authorization, but before MVC

    public Action<IEndpointRouteBuilder> BeforeDefaultEndpoints

    X
    Field Value
    Type Description
    Action<IEndpointRouteBuilder>

    Set directory path which contains the 'frameworkenc-SomePassword.key' file, and the filename will be used a the Global Encryption Key throughout the App whenever you invoke Encrypt or Decrypt

    For instance on windows it could be outside the application: C:\src\keys\

    Or it can be a relative folder within your application that is protected and not served, like app_data for both windows and linux support: ./app_data/

    Relative folders must start with ./

    public string EncKeyDir

    X
    Field Value
    Type Description
    string

    Set the cache-control max age header to a duration for all static requests

    Default: 14 days

    Remarks
    X

    Requires UseStaticFiles set to True, and the header 'max-age' cannot be added already in the response, if so this does nothing

    public int StaticFilesClientCacheSeconds

    X
    Field Value
    Type Description
    int

    Set the relative paths of where most static content is served from

    For example: new string[] { "/static", "/public" }

    This requires either you set env.WebRootPath before invoking the Options or that the built-in root path EnvironmentConfig.Current.ContentRootPath is what you want

    Remarks
    X

    Requires UseStaticFiles set to True

    public string[] StaticRequestPaths

    X
    Field Value
    Type Description
    string[]

    Adds middleware for Authorization and Authentication attributes

    public bool UseAuthentication

    X
    Field Value
    Type Description
    bool

    Adds middleware for Authorization attributes

    public bool UseAuthorization

    X
    Field Value
    Type Description
    bool

    Set to true to add services and middleware Gzip compression

    public bool UseBrotliResponseCompression

    X
    Field Value
    Type Description
    bool

    Set to true to add services and middleware for controllers and api controllers

    public bool UseControllers

    X
    Field Value
    Type Description
    bool

    Generates a single key file once, reusable across all environments, which expires in 100 years.

    Parent folder of 'ContentRoot' will be used as the destination for the key file

    - string extension methods EncryptUsingKeyRing and DecryptUsingKeyRing will use the generated file internally

    - cookies read over http will be encrypted and decrypted with the key file, if you host your app over several instances, they must all share the same key of course

    You can enable it and copy the key file out to the pipeline and other environments, and gitignore the file as it should be stored seperately

    public bool UseDataProtectionPolicy

    X
    Field Value
    Type Description
    bool

    Adds middleware which responds with a exception page usually used in development environments and test environments

    public bool UseDeveloperPage

    X
    Field Value
    Type Description
    bool

    Registers special Type Converters to the System.ComponentModel.TypeDescriptor

    For instance: it registers the .ToEnum() method as the primary method to convert a String to an Enum, so EnumValue and EnumText works

    Remarks
    X

    Note: This is used when converting data in a response to a Model within a GET or POST method for instance, do not mix it with JSON Serialization, thats something else

    public bool UseExtendedEnumModelConverter

    X
    Field Value
    Type Description
    bool

    Forwards all Microsoft.Extensions.Logging.ILogger log events to your custom ILogWriter.

    If enabled, an internal LogProvider is added to capture and route all logs to your LogWriter.

    public bool UseForwardILogger

    X
    Field Value
    Type Description
    bool

    Forwards all Log invocations to the std out and std err streams in your application.

    If enabled Log.Error() goes into the std err stream Console.Error.Write(), which hosting platforms capture and forward.

    public bool UseForwardLogToStd

    X
    Field Value
    Type Description
    bool

    Set to true to add services and middleware for forwarded headers

    public bool UseForwardedHeaders

    X
    Field Value
    Type Description
    bool

    Set to true to add services and middleware Gzip compression

    public bool UseGzipResponseCompression

    X
    Field Value
    Type Description
    bool

    Set to true to add middleware for using HSTS, which adds the Strict-Transport-Security header.

    Client side redirection

    public bool UseHsts

    X
    Field Value
    Type Description
    bool

    Set to true to add services and middleware to use http to https redirection

    public bool UseHttpsRedirection

    X
    Field Value
    Type Description
    bool

    Set to true to add MVC services

    NOTE: This also registers the controllers even if you try to set UseControllers to false

    NOTE: This registers a default media type output formatter, so all types are allowed served with exception of: .cs, .exe, .dll, .config, .iso, .dmg and a few more...

    public bool UseMvc

    X
    Field Value
    Type Description
    bool

    Set to true to register services and middleware for the OutputCache

    public bool UseOutputCache

    X
    Field Value
    Type Description
    bool

    Set to true to add ResponseCaching services

    public bool UseResponseCaching

    X
    Field Value
    Type Description
    bool

    Adds middleware for static files and sets a few default settings:

    - allows serving of unknown files types

    - compression is set to 'HttpsCompressionMode.Compress'

    - does not append a trailing slash for static files

    public bool UseStaticFilePolicy

    X
    Field Value
    Type Description
    bool

    Pass in an object that implements the interface if you want to extend View Locations

    Another option is to simply set 'ViewLocations' variable or 'AreaViewLocations'

    public IViewLocationExpander ViewLocationExpander

    X
    Field Value
    Type Description
    IViewLocationExpander

    Pass in a string array of view location formats

    Example:

    ViewLocations = new string[] { "~/Pages/{1}/{0}.cshtml" };
    Remarks
    X

    This sets non-area view locations

    public string[] ViewLocations

    X

    Simple example:

    var options = new FrameworkOptions();
    options.ViewLocations = new string[] { "~/Pages/{2}/{1}/{0}.cshtml" }
    X
    Field Value
    Type Description
    string[]

    Extension Methods

    ObjectExtensions.Json(object, bool)
    ObjectExtensions.Json(object, JsonSerializerOptions, bool, params JsonConverter[])
    ObjectExtensions.Json(object, params JsonConverter[])
    ObjectExtensions.Xml(object)

    }

    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Framework