Should I be using Web API vs Web Methods?

2019-04-05 19:41发布

问题:

I'm trying to understand web api and some news about web methods. I've heard that we should stop using web methods from a few sources. Additionally, is Web API the successor if web methods should no longer be used?

回答1:

Web methods are part of the ASMX technology. ASMX is a legacy technology, and should not be used for new development. WCF or ASP.NET Web API should be used for all new development of web service clients and servers. One hint: Microsoft has retired the ASMX Forum on MSDN.

Whether you use WCF or the ASP.NET Web API will depend on your requirements. WCF is more similar to web methods, but far richer. ASP.NET Web API can provide you with all of the features of the HTTP protocol, if your API requires them.

But in any case, stop using Web Methods in new development. Also, I suggest you ask yourself why you didn't know that ASMX had been replaced by WCF about eight years ago. What else have you been missing out on in the past eight years? What else could have taken your business to places your competitors have already gone?