Setting Up ASP.NET Core Web Application to Integrate with IRB Exchange
This tutorial shows you how to integrate the .NET client library for the Huron IRB Exchange with an ASP.NET Core MVC web application. This tutorial does not cover how to set up an ASP.NET Core MVC project. For help with this task, see the ASP.NET Core tutorials.
There are two simple steps to integrate any system with the IRB Exchange using the .NET client library. While this tutorial is specific to ASP.NET Core, you can use similar approaches for other .NET based systems.
- Configure an instance of the
ExchangeClient
class. - Use your configured
ExchangeClient
to make requests to the IRB Exchange.
Configure the ExchangeClient Class
For an ASP.NET Core MVC application, you'll need to tell the built-in dependency injection system how to build an ExchangeClient
so you can inject them into our controllers.
Open Startup.cs
and add the following to the ConfigureServices
method.
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
// Read the OrganizationId and Thumbprint from the configuration
IConfigurationSection exchangeOptions = Configuration.GetSection("Exchange").Get<ExchangeOptions>();
// Configure the service provider
services.AddSingleton(provider => ExchangeClient.Create(exchangeOptions));
}
ExchangeOptions
class defaults the Url
property to the production IRB Exchange system at https://api.huronirbexchange.com
.
If you are using the test system, the value should be set to https://test-api.huronirbexchange.com
.
In the previous code, the OrganizationId
, Thumbprint
, and Url
values are being retrieved from the configuration. Then the ExchangeClient
class was configured with the services collection. To get this working, you'll first need to update your appsettings.json
file to include an Exchange
section. Replace the values listed with your own values.
appsettings.json
{
"Exchange": {
"OrganizationId": "4b8c25a27b0f49fa89969aeb09f30487",
"Thumbprint": "24E55FB2DDF647A94BE4E0E4FCD3A36038D31481",
"Url": "https://test-api.huronirbexchange.com"
}
}
Refer to the ASP.NET Core documentation for more details on configuration.
Now that you have the ExchangeClient configured, you can inject it into one of your controllers and start using it to send and receive information from the IRB Exchange.