Creating the backend API in C#
As we move ahead, there are times when as a developer we not only need to consume APIs, but create our own APIs for others to use. Even if we find recurring usage of some functions, keeping in mind web framework strategy, we need to ensure that instead of simply creating functions for that task, we need to convert them to APIs. A big advantage of that is that the usage of our function or task will then not be limited only to Python, but it can be used in any scripting language or web language.
Here we will see a very basic approach to creating a functional API to say Hello World
in C#. As a prerequisite, we will need IIS to run the web services, and Visual Studio (Community edition is free to use) to create our own API. Later on, we will see how to consume that API in Python.
Additionally, we will ensure that the return value is in the JSON format, which is the industry standard for API communication, replacing XML.
- Invoke the C#
Web
project in Visual Studio:
- Select...