[英]MapHttpRoute in MVC WEB API
i want call delete method with its code.like 'api/vouchertype/JV0031'. 我想使用其代码调用删除方法,例如“ api / vouchertype / JV0031”。 but id section only support integer.
但id部分仅支持整数。 im add a route.
我添加一条路线。
config.Routes.MapHttpRoute("DefaultApiWithCode", "Api/{controller}/{code}", new { code = RouteParameter.Optional });
and change method accordingly. 并相应地更改方法。
[HttpDelete]
public HttpResponseMessage Delete(String code)
{
....
}
but it not worked. 但是没有用 How can i fix it ?
我该如何解决?
The request might not be processed by the UrlRoutingModule. UrlRoutingModule可能未处理该请求。 Try adding this to your web.config, making this module to handle all process requests:
尝试将其添加到web.config中,使该模块处理所有流程请求:
<modules>
...
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
...
</modules>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.