Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

WebApiConfig.cs 1.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Serialization;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web.Http;
  7. namespace GlobalMessageHandlersBot
  8. {
  9. public static class WebApiConfig
  10. {
  11. public static void Register(HttpConfiguration config)
  12. {
  13. // Json settings
  14. config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
  15. config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
  16. config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
  17. JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
  18. {
  19. ContractResolver = new CamelCasePropertyNamesContractResolver(),
  20. Formatting = Newtonsoft.Json.Formatting.Indented,
  21. NullValueHandling = NullValueHandling.Ignore,
  22. };
  23. // Web API configuration and services
  24. // Web API routes
  25. config.MapHttpAttributeRoutes();
  26. config.Routes.MapHttpRoute(
  27. name: "DefaultApi",
  28. routeTemplate: "api/{controller}/{id}",
  29. defaults: new { id = RouteParameter.Optional }
  30. );
  31. }
  32. }
  33. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...