Showing posts with label .net core. Show all posts
Showing posts with label .net core. Show all posts
Tuesday, 29 October 2019
.net core & cookies & accessing the username
add auth to the services
tell the app to use auth
create a claim for the entered username
access the username in services by using the IHttpContextAccessor
setting up elmah email notifications & error logging in .net core
Add the elmahcore package
Configure elmah with appropriate options (where logs live, where email goes etc)
tell the app to use elmah
Tuesday, 5 March 2019
.net core console adding log4net
Log4Net will not use the log settings in the appsetting.json file, it needs a log4net.config file ðŸ˜
- add package
- add Log4Net into the logging framework
Monday, 4 March 2019
.net core making config accessible to all classes
in .net framework ConfigurationManager could be accessed anywhere. The .net core method of accessing configuration requires some setup, so rather than doing that on every class set it up once and add it to the services so can be accessed via dependancy injection.
* in the startup method get a IConfigurationRoot based on the config file
* add the IConfigurationRoot object to the services collection
* in a class that needs to access configuration, get a concrete class via DI
Save the value into a private var accessible to the entire class.
* Any code in the class can access config via the private var
Subscribe to:
Posts (Atom)


















