【ASP.NET】System.Web.Routing - HttpMethodConstraint Class
你可以自己定义你的ASP.NET程序接收的get post put 或者delete请求。
使用这个约束的方式为:
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
string[] allowedMethods = { "GET", "POST" };
HttpMethodConstraint methodConstraints = new HttpMethodConstraint(allowedMethods);
Route reportRoute = new Route("{locale}/{year}", new ReportRouteHandler());
reportRoute.Constraints = new RouteValueDictionary { { "httpMethod", methodConstraints } };
routes.Add(reportRoute);
}

浙公网安备 33010602011771号