adsense

Sunday, October 29, 2023

GitHub Codespaces

 GitHub Codespaces templates provides you quick and easy development setup you need, Check this video for more information.


Regards,

Samitha

Sunday, October 22, 2023

ASP.NET Core 6/ASP.NET Core 7: Accessing Configuration during startup

 With the changes to Program.cs in .Net Core 7, we can still access confirmation options as below

appsettings.json

  "Settings": {

    "AccessTokenKey": "abcd123",

    "AccessTokenExpirySeconds": 3600,

    "RefreshTokenExpiryDays": 30

  } 

}

Program.cs

var builder = WebApplication.CreateBuilder();

ConfigurationManager config= builder.Configuration; // allows  access to  the config

IWebHostEnvironment environment = builder.Environment;// access the environment

                    var key = builder .Configuration["Settings:AccessTokenKey"]; 

Cheers,

Samitha 

Sunday, October 1, 2023

.NET 7: a connection establish error

 When working with .Net 7 WEB API projects you might have encountered following error when connection to SQL Server.

A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.).

This occurs due to a breaking change in SQL driver.

This issue can be resolved by adding TrustServerCertificate=True attribute to your connection string as shown below.


"ConnectionStrings": {

    "DefaultConnection": "Server=SQL_SERVER_NAME;Database=DATABASE_NAME;Integrated Security=True;TrustServerCertificate=True;",

}

 Cheers,

Samithaa