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
72 views
in Technique[技术] by (71.8m points)

c# - ASP.NET Web Api vs Node.js

I have quite recently started to connect a web platform that I work on to other quite complex systems mostly written in C#. Most of my experience is in web development in PHP and JavaScript And I also have some experience in writing web services in WCF.

Sadly I had experienced many difficulties in writing WCF services for my PHP web platform, slow development, very (very) complicated configurations in-order to respond well in JSON and to work RESTful and more.

Naturally I started looking around at other technologies, one in particular caught my eye Node.js which might be perfect for me because I have quite a lot of experience in JavaScript and that way I won't need my windows server anymore. My other option is of course to keep writing services in C# but switch to ASP.NET Web API instead. The switch will probably be much easier than from WCF to Node.js.

Any thoughts or suggestions in the matter? Does anyone have experience in writing web services in Node.js and can point me in the direction of a good tutorial? or am I way off and I shouldn't be using Node.js for web services at all?

question from:https://stackoverflow.com/questions/22459356/asp-net-web-api-vs-node-js

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

1 Reply

0 votes
by (71.8m points)

I have just recently started working on express.js. Let me tell you it's not for the fainthearted. The whole mentality of "If you are already familiar with JS then that's half the battle." really couldn't be further from the truth. I.E. if you are a hardcore devops guy like me.

I have a unified build process for all my asp.net application build, test and coverage reporting, deployment, configuration management and code quality analysis all setup and automated. It takes me literally 5 min to setup a Build process around a new project and have it tested, analysed, staged and shipped off to a production environment. (And really so should all the devs in the world. But hey, who am I kidding.) Then there's the monitoring, logging, performance analysis and profiling. Again all well unified, orchestrated and centrally managed.

I'm not saying node.js/express.js doesn't have those, but you have to develope/learn a COMPLETELY NEW set of services and platform just to run node.js.

Hammering out a bunch of code is one thing. Running a production system on a foreign technology is something else altogether.

Unless you looking for trouble ahem i mean, challenge :D, stick to WebAPI. WebDeploy is a god send.

BTW. Use BasicHttpBinding with your WCF endpoint and get PHP to generate the client class from the WSDL. Yes. Soap is your answer, not an "easier to use rest". Something like https://code.google.com/p/php-wsdl-creator/. Archiving the WSDL from the WCF endpoint also allows you to track with pin point accuracy of your service signature and format changes. It ensures type safety, and handles ser/de for you. I don't care much about how ugly the message looks if I don't have to deal with it. And yes I have done it before with PHP and python. Works flawlessly.


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

...