https://github.com/moesif/moesif-aspnet-webapi-selfhost-example
https://github.com/moesif/moesif-aspnet-webapi-selfhost-example
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/moesif/moesif-aspnet-webapi-selfhost-example
- Owner: Moesif
- License: apache-2.0
- Created: 2020-06-09T05:02:09.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T10:39:36.000Z (almost 3 years ago)
- Last Synced: 2025-02-24T00:28:37.305Z (7 months ago)
- Language: C#
- Size: 43.9 KB
- Stars: 1
- Watchers: 8
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Moesif .NET Web API SelfHost Example
[Moesif](https://www.moesif.com) is an API analytics platform. [Moesif.Middleware](https://github.com/Moesif/moesif-dotnet)
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](https://docs.microsoft.com/en-us/aspnet/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api) which is less common.
If you're looking for a .NET app running on IIS (more common), view the [.NET Framework example](https://github.com/Moesif/moesif-netframework-example).## Key files
Moesif Middleware's [github readme](https://github.com/Moesif/moesif-dotnet) 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_](https://www.moesif.com/).
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_](https://www.moesif.com/), click on the top right menu,
and then clicking _Installation_.```csharp
Dictionary moesifOptions = new Dictionary
{
{"ApplicationId", 'Your Application ID Found in Settings on Moesif'},
{"LogBody", true},
...
}
```3. 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.