четвер, 26 серпня 2010 р.

Status code groups from web servers

Web servers give to browser responses in different areas of digits. It not needed for me as for developer to memorize all response codes, but it was needed in one project to know what response means. I found some useful information and I'd like to share it (in the Self training Kit)
Status code group Description
1xx Informational: received request, continue process
2xx Action was received, understood and accepted
3xx This is redirect command. Further action must be taken to complete the request.
4xx Everybody knows that this is error codes :) like page is not available, etc...
5xx This means that web server has some problems

Difference between get and post


I'm doing web programming for almost 5 years. But only today I discovered for myself what is difference between GET and POST. It's good that nobody at job interviews asked me what is difference between them.

The difference is very simple. The first request of the web page to the web server is called GET. All others are called POST.

That's why in C# for asp.net it is valid code:

if(!Page.IsPostBack) //this means we have GET
{
//do your code for page initialisation
}
else
{
//analyze requests for web browsers
}




According to book self training book from Microsoft Press usual steps is like this:
1. A user uses his or her Web browser to initiate a request for a Web server resource. (Hi or she initialize get)
2. HTTP is used to send a GET request to the Web server. (through web browser, like IE, FF, Chrome, etc...)
3. The web server   processes the GET request on the server (typically locating the requested code and running it). (it could be Apache, Kassinin, IIS, ...)
4. The Web server then sends a response back to the Web browser. The HTTP protocol is used to send the HTTP response back to the Web browser.
5. The user’s Web browser then processes the response (typically HTML and JavaScript) and renders the  web page for display to the user.
6. The user may then enter data and perform an action such as clicking a submit button that causes his or her data to be sent back to the Web server for processing.
7. HTTP is used to POST the data back to the Web server.
8. The Web server then processes the POST request (again, calling your code in the process).
9. The Web server then sends a response back to the Web browser. HTTP is used to send the HTTP response to the Web browser.
10. The Web browser again processes the response and displays the Web page to the user.



This process is repeated over and over during a typical Web application session.