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

asp.net - Difference between webservice, web methods & server side code?

Some questions confusing me guys, I'm just new to web services altogether.

  1. What is the difference between web service, web methods and server side code ?

  2. Where is web service preferred over server side methods?

  3. Where are web methods preferred to be used ?

  4. How does web service differ from server side post back ?

  5. Are web services light weight ? Can they be used to save long web forms as well ?

  6. In an enterprise web application, which one of these should I use frequently and why?
See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

What is the difference between web service, web methods and server side code ?

A web service is an exposed end point that is normally used as an API, or in other words its end user is typically another application rather than a user interface. A web method is a particular method that is exposed over a web service.

On the other hand, server-side code applies to any ASP.NET web page, web service, or other technology for general implementation of its functionality.

Where is web service preferred over server side methods?

Web services excel at making an application compatible with other programming platforms or for serving up AJAX requests to a web page. There are many other uses, but typically using WCF or HttpHandlers are better options in those cases.

Where are web methods preferred to be used ?

Web methods can be used in any .aspx page or more typically in a .asmx (web service) file.

How does web service differ from server side post back ?

A server-side postback occurs when a web page posts data to the server for processing. A web service is completely different - it is an endpoint that is exposed for consumption by another application (or within the same application).

Are web services light weight ? Can they be used to save long web forms as well ?

No, web services are not light weight, in fact they are quite the opposite because they generally receive and respond to data using XML (a bulky format). However, this makes them very easy to use with other programming languages.

In an enterprise web application, which one of these should I use frequently and why?

This is a highly subjective question. Each technology in the .NET framework has a set of features that it excels at and can usually do several other things (but not very well). Each tool has its place, it is just a matter of matching the tools to use with the requirements of your project.

However, judging by the rest of your questioning, it sounds like you are just putting together a typical website that doesn't require an API, in which case it would be best to use .aspx pages and code behind.


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

...