Asp.net WEB API - 如果我使用 POST 而不是 PUT 和 DELETE 会出现什么问题? [英] Asp.net WEB API - What problems could arise if I use POST instead of PUT and DELETE?

查看:19
本文介绍了Asp.net WEB API - 如果我使用 POST 而不是 PUT 和 DELETE 会出现什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 Web API,虽然我发现创建我需要的方法和一些配置真的很容易,但现在我遇到了一个我不知道如何解决的问题.

一些会使用我的服务的应用程序很旧,不支持 DELETE 和 PUT 方法(例如 j2me 应用程序)

我发现可以通过传递这样的东西来进行某种方法模拟:

_method=DELETE|PUT

但是,我不确定 Web API 是否能够解释这一点,此外,我对如何做到这一点一无所知.由于这些原因,我正在考虑仅使用 POST 方法来处理更新和删除.话虽如此,如果不使用所有标准方法,我会期待什么并发症??

一如既往地非常感谢任何帮助

提前致谢.

PD如果有人知道如何将带有 _method 的 POST 路由到 DELETE() 或 PUT()

,那就太好了

解决方案

感谢 Robert Levy 我知道这个问题是如何命名的.一旦我知道问题是什么,我做了一点谷歌搜索,在这个博客中我找到了解决它的方法:

http://www.hanselman.com/blog/HTTPPUTOrDELETENotAllowedUseXHTTPMethodOverrideForYourRESTServiceWithxASPWeb>

I'm just starting to use Web API and though I found it really easy to create the methods and some configurations I needed, now I run into a problem I don't know how to solve.

Some of the applications that will consume my services are very old and don't support DELETE and PUT methods (j2me applications for example)

I have found that it is possible to do some kind of method emulation by passing something like this :

_method=DELETE|PUT 

However, I'm not really sure if Web API will be able to interpret this and besides, I don't have the faintest idea how to do it. For those reasons I'm thinking in just using POST methods to handle updates and deletes. Having said that, what complications can I expect from not using all the standard methods??

As always any help will be GREATLY appreciated

Thanks in advance.

P.D. It it'd be great if anyone knew how to make the a POST with a _method be routed to the DELETE() or PUT()

解决方案

Thanks to Robert Levy I knew how this problem was called. Once I knew what the problem was , I did a little googlig and in this blog I found how to solve it:

http://www.hanselman.com/blog/HTTPPUTOrDELETENotAllowedUseXHTTPMethodOverrideForYourRESTServiceWithASPNETWebAPI.aspx

这篇关于Asp.net WEB API - 如果我使用 POST 而不是 PUT 和 DELETE 会出现什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆