How to integrate in .Net Core Web ?

Estimated reading: 3 minutes 657 views

To integrate Visual Guard in your web application for .net core, you must:

  • Add the assemblies of Visual Guard as references of your project.
  • Insert the code to enable the security in your application.
  • Create a Visual Guard repository and declare your application. This repository
    will contain all security items (users, roles, permissions …) of your
    application.
  • Generate the Visual Guard configuration files
    by using the Visual Guard console. These configuration files will be needed to
    connect your application to the repository.


Referencing Visual Guard assemblies

  • Open the solution of your project in Visual Studio.
  • In the solution explorer, expands the project node.
  • Right-click the Project node for the project and select Add Reference
    from the shortcut menu.
  • Select these 3 assemblies from this path – C:\Program Files (x86)\Novalys\Visual Guard X version\Bin
    • Novalys.VisualGuard.Security
    • Novalys.VisualGuard.Security.Core.dll
    • Novalys.VisualGuard.Security.<RepositoryType> (Files, SQLServer or Oracle)
  • Select this assembly from this path – C:\Program Files (x86)\Novalys\Visual Guard X version\Bin\VGWebForm.Core
    • Novalys.VisualGuard.Security.WebForm.Core.dll
  • And, then click the Select button, and then click the OK button

      Description of the Assemblies

      • Novalys.VisualGuard.Security contains the main Visual Guard classes.
      • Novalys.VisualGuard.Security.Files contains the classes needed to access
        to a file based repository.
      • Novalys.VisualGuard.Security.SQLServer contains the classes needed
        to access to a repository stored in a Microsoft SQLServer database (SQLServer 2005
        or higher). Available only in Visual Guard Enterprise Edition
      • Novalys.VisualGuard.Security.Oracle
        contains the classes needed to access to a repository stored in an Oracle database
        (8i or higher). Available only in Visual Guard Enterprise Edition
      • Novalys.VisualGuard.Security.Core contains all classes required to support .Net Core applications.
        This assembly is needed only if you want to integrate Visual Guard in .net core applications.
      • Novalys.VisualGuard.Security.WebForm.Core.dll contains all classes required to support Web applications for .net core.
        This assembly is needed only if you want to integrate Visual Guard in .net core web applications.
      Note Note
      In the list of assemblies, Visual Studio can display different versions of the
      Visual Guard assemblies. You must select the assembly corresponding to the version
      of the framework and target (x64, x32, or Any CPU) used in your project.
      Note Note
      Please make sure Visual Guard configuration files are properly generated

      • VisualGuardConfiguration.config
      • VisualGuardConfiguration.exe.config
      Note Note
      Once the Visual Guard assemblies are referenced into project, you need to mark “Copy Local” property to “true” for each assembly.

      Install packages using Nuget Packages Manager

      • Microsoft.AspNetCore.App 2.2.0
      • System.Configuration.ConfigurationManager 4.5.0
      • System.Drawing.Common 4.5.1
      • System.DirectoryServices 4.5.0


      Apply changes in your code

      • In Method – ConfigureServices()
        services.AddVGConfig(this.Configuration);
        web Core startup 2
      • In Method – Configure()
        C#
        app.UseVGAuthentication();

        Web Core startup


      Common issue while integrating VisualGuard in .net core web applications.

      • InvalidOperationException: Unable to resolve service for type ‘Microsoft.AspNetCore.Http.IHttpContextAccessor’.
        Solution:
        Please check if you have added following code in Method ConfigureServices() of Statup.cs file.
        public void ConfigureServices(IServiceCollection services) {     services.AddVGConfig(this.Configuration); }


      How to secure WebService with Visual Guard