Moesif is an API analytics platform. Moesif.Middleware is a middleware that makes integration with Moesif easy for .NET applications.
This is an example of NET Framework 4.6.2 application with Moesif integrated as a self hosted executable which is less common. If you're looking for a .NET app running on IIS (more common), view the .NET Framework example.
Moesif Middleware's github readme already documented the steps to setup Moesif Middleware. But here is the key file where the Moesif integration is added:
Program.cs
contains the main C# application.Settings/MoesifOptions.cs
has the Moesif middleware related settings.
-
Restore Nuget packages using Visual Studio or via command line.
-
Be sure to edit the
Settings/MoesifOptions.cs
to add your Moesif Application Id.
Your Moesif Application Id can be found in the Moesif Portal. After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.
You can always find your Moesif Application Id at any time by logging into the Moesif Portal, click on the top right menu, and then clicking Installation.
Dictionary<string, object> moesifOptions = new Dictionary<string, object>
{
{"ApplicationId", 'Your Application ID Found in Settings on Moesif'},
{"LogBody", true},
...
}
- See
ProductController.cs
for some sample ASP.NET Web API routes that you can test such as the below GET:
GET http://localhost:9000/api/product/123
You can also try a POST request:
POST http://localhost:9000/api/product
{
"Id": 1234,
"Name": "Chair",
"Category": "Furniture",
"Price": 0.0
}
The sample API calls should be logged to Moesif.