What is the difference between client-side and server-side code in web development?

Asked

Viewed 8,320 times

16

I’m studying ASP.NET through a book called Professional: ASP.NET 4.5 in C# and VB and at various times the author talks about code client-side and server-side, would like to know the difference.

4 answers

25


Server-side relates to the server side (your application server, e.g.: IIS). Client-side relates to the client side (e.g.: a web-browser).

The interaction works as follows: Server Client User

  • The server provides for the client one exit: it serves the desired page or files (download).
  • The server interprets the entree of client: the client sends information (form) to the server and files (upload).
  • The client provides for the user one exit: the rendered page he obtained from the server (html).
  • The client interprets the entree of user: the user enters different data into the client (and this eventually sends it to the server).

Example:

  1. Client User: The user enters the address http://www.google.com in your web browser.
  2. Client Server: Then the client re-queries the page to the google server.com.
  3. Client Server: The server receives the request, retrieves the page and sends it to the client.
  4. Client User: The client renders the page (HTML) received by the server and displays to the user.
  5. Client User: The user enters a search in the search field of the page and clicks "Search".
  6. Client Server: The client sends the request with the search term informed by the user.
  7. Client Server: The server mounts the page with the search results and sends it to the client.
  8. Client User: The client, when receiving from the server the page with the search results, renders the new page and displays to the user.

And so on...

  • 3

    Why are there so many negative votes in the two best answers? Besides, why are there so many negative votes in all the answers here? (on that answer, "" is an arrow? is not rendered correctly here)

  • @Guilhermebernal I can’t see here, there are so many downvotes.? :

  • @Guilhermebernal Yes is an arrow. Which browser are you using? If you don’t render in most of the people’s browser I switch to simply ->.

  • @Guilhermebernal I agree! The question may be simple, but it does not justify "punishing" those who answer. I have already done simple questions before - motivated only by the language barrier - and I have answered many others too, without having this kind of problem.

  • Also not showing the arrow here (Chrome).

  • Given the amount of correct answers but too short I came to think of writing something more complete with a flow example, but @Alles has already gone ahead. Does anyone else think that the correct answer should be this?

  • I switched to an arrow theoretically "HTML safe". If it doesn’t work warn. Thanks :)

  • You could say something about client-side. I think they are two ways, one is when the request does not go to the server (example, when the user clicks on something that changes the color of a button or other widget, IE, just make a Javascript that changes the color of the object in question) or when it comes to an Ajax request that aims to change a piece of the DOM (not the entire page) with data brought from the server. The latter is the one that I have more difficulty visualizing due to lack of experience with web development and so I seek clarification in OS questions like this.

Show 3 more comments

13

The difference is simply where the code will run: on the server where ASP.NET is installed (server-side) or in the browser from which the system will be accessed (client-side).

Although it is possible to develop an application/site exclusively using HTML and CSS on the client side (generating the pages dynamically on the server, and using only links and/or forms for data entry), it is often desirable that certain code be executed in the user’s browser, for example for validation or usability improvement purposes. In this case, the relevant section should be written in - or converted to - Javascript, which is the only language universally accepted by browsers. Other forms of client code could be plugins like Flash or Java.

It should be remembered that the user agent does not necessarily need to be a browser (browser) - any application that implements the client side of the HTTP protocol can interact with the application server (without necessarily offering Javascript support).

  • 4

    "answered 55 seconds ago", already with -2 votes. Putz, there are people here who are ninja when it comes to voting against. Let’s take it easy folks.

  • 6

    What exactly is the difference between my answer and the other two on this page? Is it the fact that I haven’t mentioned that the client code is [or is converted to] Javascript? Or is there something else wrong with that answer? Comment!

  • 1

    Application only with HTML and CSS? These features are used to create static pages, not applications, and even a simple website, without using a server-side language, require a minimum of JS, even to define a CSS rule for some specific browser for example...

  • 5

    @Kennyrafael hi? It is perfectly possible to create an application using only HTML and CSS on the client side. It is sufficient that these pages are dynamically generated by the server and contain links and/or forms...

  • If it’s being generated DYNAMICALLY by the server, it’s because it has some language running behind it, if it’s just static content, it’s not an application, an application has features, however simple they are, HTML and CSS can be part of an application, will never BE the application.

  • @Kennyrafael And what exactly am I saying that contradicts what you’re saying?!!! I updated my answer to see if it’s clearer... :)

  • @mgibsonbr , it is worth mentioning that Java or Flash for rich interfaces are currently in disuse?

  • @mgibsonbr I asked for a complement in the accepted answer that if you want to do also in your reply, feel free. :)

Show 3 more comments

2

Client-side = runs client-side, e.g.: Javascript.

Server-side = runs on the server, e.g.: PHP, C#, etc.

2

Client-side is the one that runs on the client side (e.g. Javascript), i.e., in the user’s browser, Server-side runs on the server (e.g. PHP, JAVA, . NET...)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.