Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
390 views
in Technique[技术] by (71.8m points)

c# - Asp.net WEB API - What problems could arise if I use POST instead of PUT and DELETE?

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()

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is fairly common and there is even a somewhat standard http header for it. It's called "http method override" and you'll find some good stuff in this question X-HTTP-Method-Override gives NotFound (404) on ASP.NET Web API


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...