();
Console.WriteLine( $"{dx2.GetPong()}" );
ReleaseContainer();
}
private static void ReleaseContainer()
{
// dispose container and services in it
if(ioc is IDisposable)
{
Console.WriteLine("Can dispose stuff !");
( (IDisposable)ioc).Dispose();
}
}
}
}
}}}
=== Example output ===
{{{
Hello World DI!
TestOne
Constructed dummy 37a7cced-15c3-4b33-9eec-55f0fb58ce8c !
Pong 37a7cced-15c3-4b33-9eec-55f0fb58ce8c !
Pong 37a7cced-15c3-4b33-9eec-55f0fb58ce8c !
Constructed snafu 619160b5-6e67-4396-8555-f453bd1ad06f !
Snafu 619160b5-6e67-4396-8555-f453bd1ad06f related with Pong 37a7cced-15c3-4b33-9eec-55f0fb58ce8c !!
Snafu 619160b5-6e67-4396-8555-f453bd1ad06f related with Pong 37a7cced-15c3-4b33-9eec-55f0fb58ce8c !!
Constructed transx 6cf6600a-e622-46fd-8d10-3b6015601911 !
Transx 6cf6600a-e622-46fd-8d10-3b6015601911 !
Constructed transx c666091c-efe9-407f-8659-6c1bdc7e2b7f !
Transx c666091c-efe9-407f-8659-6c1bdc7e2b7f !
Constructed transx 421a63ca-0e93-4656-ba5c-c8909774827c !
Transx 421a63ca-0e93-4656-ba5c-c8909774827c !
Can dispose stuff !
Disposing transx 421a63ca-0e93-4656-ba5c-c8909774827c !
Disposing transx c666091c-efe9-407f-8659-6c1bdc7e2b7f !
Disposing transx 6cf6600a-e622-46fd-8d10-3b6015601911 !
Disposing snafu 619160b5-6e67-4396-8555-f453bd1ad06f !
Disposing dummy 37a7cced-15c3-4b33-9eec-55f0fb58ce8c !
TestTwo
Constructed dummy 7233afd9-9f2e-43a4-ae1a-bc0abba6abc7 !
Constructed snafu 10298883-4f16-4383-b5b7-ce9e5ad90715 !
Snafu 10298883-4f16-4383-b5b7-ce9e5ad90715 related with Pong 7233afd9-9f2e-43a4-ae1a-bc0abba6abc7 !!
Pong 7233afd9-9f2e-43a4-ae1a-bc0abba6abc7 !
Pong 7233afd9-9f2e-43a4-ae1a-bc0abba6abc7 !
Can dispose stuff !
Disposing snafu 10298883-4f16-4383-b5b7-ce9e5ad90715 !
Disposing dummy 7233afd9-9f2e-43a4-ae1a-bc0abba6abc7 !
}}}
== Eager service bean instantiation ==
To instantiate a service/bean before being used else where add it as an argument in the Configure method that belongs to the Startup class.
== RBAC role based authorization ==
* https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.0&tabs=visual-studio%2Caspnetcore2x
* https://docs.microsoft.com/en-us/aspnet/core/security/authorization/secure-data?view=aspnetcore-2.0
* https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles?view=aspnetcore-2.0
Identity is enabled for the application by calling UseAuthentication in the Configure method. Startup.cs in dotnet core to init the services/beans.
In ASP.NET Core MVC, views are .cshtml files that use the C# programming language in Razor markup.
* About.cshtml
{{{
@{
ViewData["Title"] = "About";
}
@ViewData["Title"].
@ViewData["Message"]
Use this area to provide additional information.
}}}
* HomeController.cs
{{{#!highlight csharp
// method About related with About.cshtml
// ViewData["Message"] defined in the method and accessed inside the view in the About.cshtml
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
return View();
// return explicit view Orders
// return View("Orders");
// return both a view and a model
// return View("Orders", Orders);
}
}}}
View discovery searches for a matching view file in this order:
* Views/[ControllerName]/[ViewName].cshtml
* Views/Shared/[ViewName].cshtml
Pass data to views using several approaches:
* Strongly-typed data: viewmodel
* Weakly-typed data
* ViewData (ViewDataAttribute)
* ViewBag