C# library to dynamically expose API end-points without creating them. You don't need to create any models or write code. Just setup the environment as defined in the Web.config and Global.asax of your ASP.Net WebForm website and create an empty Default.aspx page. That's it.
This works with MS SQL Server databases at the moment.
Now this works for all the verbs- GET, POST, PUT and DELETE as expected.
- Create a ASP.Net Empty WebForms project, preferrably .Net Framework Ver 4.0 and above.
- Add reference to Proinfocus.AutoAPI.dll in your project.
- Add a Global.asax, Web.config and a Default.aspx empty page.
- Copy contents as available in this repository to the respective pages.
- Run the project. That's it.
The end-points are basically your SQL Server database tablenames. For eg. if your table name is Products, then the end-point will be https://localhost:12345/api/products
, which will list all the records in this table.
If you want to get a particular item by Id, you can execute: https://localhost:12345/api/products/1
.
You can also define the fields you require in the output by using the following example:
https://localhost:12345/api/products/1/Id,ProductName,Price
The above query to the end-point will fetch the the Product having Id=1 and the output will be just Id, ProductName and Price. If you want to get all products, but the Id, ProductName and Price, just replace the Id=1 to Id=0, which instructs the api to get all the products.
Sometimes it is required that there are some important information in certain Tables, which you want the service to ignore querying for. It is possible, just by adding them to the ProtectEndPoints collection, as mentioned in the Global.asax file's Application_Start method.
If you want to avoid disclosing the Tablenames to your users or to make a better End-point name, you can do it by adding them to the EndPointAliases collection, as mentioned in the Global.asax file's Application_Start method.