Skip to content

Instantly share code, notes, and snippets.

@tugberkugurlu
Created July 13, 2012 14:27
Show Gist options
  • Save tugberkugurlu/3105188 to your computer and use it in GitHub Desktop.
Save tugberkugurlu/3105188 to your computer and use it in GitHub Desktop.
Don't allow param for POST
protected void Application_Start(object sender, EventArgs e) {
var config = GlobalConfiguration.Configuration;
var routes = config.Routes;
routes.MapHttpRoute(
"DefaultHttpRoute",
"api/{controller}/{id}",
new { id = RouteParameter.Optional },
new {
httpMethod = new HttpMethodConstraint(
new[] { HttpMethod.Get, HttpMethod.Delete, HttpMethod.Put }
)
}
);
routes.MapHttpRoute(
"DefaultPostHttpRoute",
"api/{controller}",
new { },
new {
httpMethod = new HttpMethodConstraint(
new[] { HttpMethod.Post }
)
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment