Coding adventures with Happy results

Securing .Net 4.5 and above with identity server 4

Sunday, October 21, 2018 | 12:35:35 PM | C# Identity Server 4


A few days ago I’ve been asked to provide a sample on how to secure a C# Web API using Dot Net Framework 4.5  and Identity Server 4.

In this Post, I’ll demonstrate what you need to install in order to secure an API  with Identity Server 4.

 

Create Your Project

From the menu select File > New Project

In the New Project Dialog create an ASP .NET Web Application (.NET Framework). In the framework selection, you can choose .Net Framework 4.5 and above.

 

public static IWebHost BuildWebHost(string[] args) =>
         WebHost.CreateDefaultBuilder(args)
             .UseStartup<Startup>()
                .ConfigureLogging((hostingContext, logging) =>
                {
                    logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
                    logging.AddEventLog(new EventLogSettings()
                    {
                        SourceName = "HappyCoderScoure",
                        LogName = "HappyApplication",
                        Filter = (x, y) => y >= LogLevel.Information
                    });
                    logging.AddConsole();
                })
             .Build();