Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 2.2 KB

README.md

File metadata and controls

32 lines (23 loc) · 2.2 KB

AutoAPI

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.

Note:

This works with MS SQL Server databases at the moment.

Updated:

Now this works for all the verbs- GET, POST, PUT and DELETE as expected.

Setup

  1. Create a ASP.Net Empty WebForms project, preferrably .Net Framework Ver 4.0 and above.
  2. Add reference to Proinfocus.AutoAPI.dll in your project.
  3. Add a Global.asax, Web.config and a Default.aspx empty page.
  4. Copy contents as available in this repository to the respective pages.
  5. Run the project. That's it.

Sample End-points

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.

Restrict End-points

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.

End-point Aliases

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.