Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
API Routes in WebApiConfig
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute("product-get", "products/{productId}",
new { controller = "Products", action = "GetProduct", logging = false },
new { httpMethod = new HttpMethodConstraint("GET") });
config.Routes.MapHttpRoute("product-list", "products",
new { controller = "Products", action = "GetProducts", logging = false },
new { httpMethod = new HttpMethodConstraint("GET") });
config.Routes.MapHttpRoute("product-create", "products",
new { controller = "Products", action = "PostProduct", logging = true },
new { httpMethod = new HttpMethodConstraint("POST") });
config.Routes.MapHttpRoute("product-update", "products/{productId}",
new { controller = "Products", action = "UpdateProduct", logging = true },
new { httpMethod = new HttpMethodConstraint("PUT") });
config.Routes.MapHttpRoute("product-delete", "products/{productId}",
new { controller = "Products", action = "DeleteProduct", logging = true },
new { httpMethod = new HttpMethodConstraint("DELETE") });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment