Skip to content

Moesif/moesif-aspnet-webapi-selfhost-example

Repository files navigation

Moesif .NET Web API SelfHost Example

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.

Key files

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.

How to run this example.

  1. Restore Nuget packages using Visual Studio or via command line.

  2. 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},
          ...
      }
  1. 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages