What happens when we type a URL in the browser (In Depth)?

If you are reading this then i would recommend to read this  article first for a clear visibility that what we will understand in depth 🙂

https://jogendras.wordpress.com/2017/07/17/what-happens-when-we-type-a-url-in-the-browser/

Have you ever wondered, precisely – 

  • What happens in the background when we type a URL in the browser?
  • How does a web page life-cycle sequence work?
  • How browser knows, where to send request for the requested page?
  • What happens on the Web Server when a request for a web page comes in?
  • How does the Web server handle the incoming request?
  • How is the HTML that is emitted to the client generated?
  • How browser renders the page on the screen?
  • Etc…

If you are also looking answers of above mentioned questions then this article is definitely for you. In this article, we will take a deeper look at the sequence of events that take place when we visit a ASP.NET page URL –

  1. URL is typed in address bar of the browser
  2. The browser parses the URL to find the protocol, host, port, and path. Ex- http://www.jogendras.com/about/ will be parsed as-
    • Protocol – http
    • Hostname – http://www.jogendras.com
    • URL path – /about
  3. Browser checks cache, if requested object is in cache and is fresh then return response from cache.
  4. The browser looks up the IP address for the entered domain name.  When we want to connect to www. google.com, we actually want to reach out to a server where web application is hosted. One such server is having an IP address of XX.XXX.XXX.XX. Now, if we type http:// XX.XXX.XXX.XX in the browser, this will take us to www. google.com itself. Which means, www. google.com and http://XX. XXX.XXX.XX are nothing but same stuff. But, it is not so. 
    As google has multiple servers in multiple locations to cater to the huge volume of requests. Thus we should let application decide which server is best suited to our needs. Using www. google.com does the job for us. When we type www. google.com DNS services comes into play and resolves the URL to a proper IP address. The DNS lookup proceeds as follows-

    • Browser cache – The browser maintain cache of DNS records for some time. So, this is the first place to resolve DNS queries. If not found in browser’s cache then it makes a system call to underlying OS to fetch the record.
    • OS makes a DNS lookup and replies the IP address to the browser: OS uses the DNS client service to find the IP address- win + r => services.mscDNSCIt first checks in Hosts file and then-
      • OS cache – If not found in hosts file then it checks in OS local DNS cache.
      • Router cache – If above steps fail to get a DNS record, the search continues to your router which has its own cache
      • ISP DNS cache – If above also fails then search moves on to ISP’s DNS server, first, it tries in its cache if not found then ISP’s DNS recursive search comes into the picture.
      • Recursive search – If everything fails then recursive search begins from the root level namesever.  For the DNS enthusiasts – here is a great guide worth reading
  5. As, now browser knows the domain’s IP address so a socket needs to be opened from the user’s computer to that IP number, on the port specified (most often port 80)
  6. When a connection is open browser sends the HTTP request to the host server.
  7. On the server protocol listeners receive protocol-specific requests. In this case we have http request so HTTP/S listener i.e http.sys (Hypertext Transfer Protocol Stack) first listen the http request from network. Now, HTTP.SYS is Responsible to pass the request to the particular web server application i.e IIS or Apache etc.. and send response back to the client browsers… Let’s assume we have .net web application request so request will go to IIS.image1abhijit20jana_634041501195202656_withall
    • HTTP.sys contacts WAS to obtain information from the configuration store
    • WAS requests configuration information from the configuration store, applicationHost.config
    • The WWW Service receives configuration information, such as application pool and site configuration
    • Now we know the application pool so WAS starts a worker process(w3wp.exe) for the application pool to which the request was made.
    • The worker process “w3wp.exe” looks up the URL of the request to load the correct ISAPI (Internet Server Application Programming Interface => a low level unmanged Win32 API) extension. ASP.NET interfaces with IIS through an ISAPI extension. ISAPI is the first and highest performance entry point into IIS. 
    • Depending on the extension ASP.NET routes the request to an appropriate handler that is responsible for picking up requests.

Coming Soon….. 🙂

 

https://docs.microsoft.com/en-us/iis/get-started/introduction-to-iis/introduction-to-iis-architecture

Beginner’s Guide: How IIS Process ASP.NET Request

 

Programming is Easy…

Advertisements

What happens when we type a URL in the browser?

If you are curious to know what happens in the background when we type a URL in the browser then this article is definitely for you. Below are the sequence of events that occurs when we enter a URL in the browser’s address bar-

  1. You type the URL into address bar in your preferred browser
  2. The browser parses the URL to find the protocol, host, port, and path.
  3. Browser checks cache, if requested object is in cache and is fresh, skip to #15
  4. Browser asks OS for entered domain’s IP address
  5. OS makes a DNS lookup and replies the IP address to the browser
  6. Browser opens a TCP connection to the server
  7. When a connection is open, browser sends the HTTP request to the host
  8. The host forwards the request to the server software (most often Apache, IIS) configured to listen on the specified port
  9. Server handles the incoming request i.e server inspects the request (most often only the path), and launches the server plugin needed to handle the request (corresponding to the server language you use, PHP, Java, .NET, Python?)
  10. The server plugin gets access to the full request, and starts to prepare a HTTP response.
  11. Server sends the HTTP response back to the browser
  12. Browser receives HTTP response and may close the TCP connection, or reuse it for another request
  13. Browser checks if the response is a redirect or a conditional response (3xx result status codes), authorization request (401), error (4xx and 5xx), etc.; these are handled differently from normal responses (2xx)
  14. If cache-able, response is stored in cache
  15. Browser decodes response (e.g. if it’s gzipped)
  16. Browser determines what to do with response (e.g. is it a HTML page, is it an image, is it a sound clip?) Browsers often use the MIME-type to determine what default action to do when a resource is fetched.
  17. If response is HTML then browser parses the HTML. A DOM tree is built out of the response HTML. New requests are made to the server for each new resource that is found in the HTML source (typically images, style sheets, and JavaScript files). Go back to step#7 and repeat for each resource. StyleSheets are parsed, and the rendering information in each gets attached to the matching node in the DOM tree. Javascript is parsed and executed, and DOM nodes are moved and style information is updated accordingly. The browser renders the page on the screen according to the DOM tree and the style information for each node
  18. Browser renders response, or offers a download dialog for unrecognized types

 

Hopefully this gives you a better idea of how a URL get proceeds 🙂

 

Programming is Easy…

Does Session use cookies in Asp.Net?

It’s very confusing for many developers that session use cookies or not, and also a interesting interview question for .net developer 🙂 Let’s understand the relation between session and cookies-

Does session use cookies? Answer is- YES and NO.

One more confusion?

While using session in the application we have two things which are SessionID which is used to uniquely identify the session variables and Session Value which is the actual data stored in the session variables.

As session is a server side and cookies are client side state management techniques, so session actual data always stored on the server memory by default. The following list describes the available session storage modes-

  • InProc mode, which stores session state in memory on the Web server. This is the default.
  • StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
  • SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
  • Custom mode, which enables you to specify a custom storage provider.
  • Off mode, which disables session state.

I hope it’s clear that session data is stored on the server and has no relationship with the cookies.

Now let’s understand the session keys storage types-

 

 

 

 

Session and cookies relationship are limited to only session keys not session value.

 

Session use cookies – Yes :  By default Session key is stored in an HTTP  non-persistent cookie that the client sends to the server (and server to client) on each request/responses. The server can then read the key from the cookie and re-inflate the server session state.

If we will try to run below code after disabled the cookies then it will not work that proves that session use the cookies.

Session use cookies – No : There is the possibility that browser does not support cookie or disabled, then asp.net can not create a cookie to store session keys. ASP.NET offers an alternative in the form of cookieless sessions. You can configure your application to store session keys not in a cookie, but in the URLs. This can be done by setting cookieless=”true” in the web.config file  as-

<configuration>
<sessionstate cookieless=”true” />
</configuration>

http://localhost/(lit3py55t21z5v55vlm25s55)/Application/SessionState.aspx

 

Programming is Easy…

What is ES-5, ES-6 or ES2015 and TypeScript? [ES = ECMAScript]

Before discussing ES5 or ES6 let’s discuss what actually is ECMAScript-

ECMAScript is a standard, JavaScript is an implementation of that standard. ECMAScript defines the standard and browsers implement it.

In a similar way, HTML specifications (most recently HTML5) are defined by the organising body and are implemented by the browser vendors. Different browsers implement specifications in different ways, and there’s varying amounts of support for different features.

  1. ES5-  ES5 is the JavaScript we know today and use in web applications. It does not require a build step to transform it into something that will run in today’s browsers.
  2. ES6 – Also called ES2015 is the next iteration of JavaScript with many enhanced features(http://es6-features.org) but it does not run in today’s browsers. So we need a transpiler like Babel that will export ES5 code means it will compile ES6 code to ES5 code that today’s browsers support and can be run easily in the today’s browsers.
  3. TypeScript – TypeScript is a typed superset of JavaScript that also compiles to plain JavaScript. This is pulling in features from ES6, ES7… Or future’s JavaScript. It help us to write safe JavaScript code means mistakes in JavaScript code can be noticed at development time due to it’s compile feature. As this is the superset of JavaScript so it contains JavaScript and some additional features as well.

 

We can view the all latest specification at-

ECMAScript – http://www.ecma-international.org/default.htm

ES2015 or ES6 – http://www.ecma-international.org/ecma-262/6.0/

ES2016 – https://www.ecma-international.org/ecma-262/7.0/

ECMA Proposals-  https://github.com/tc39/proposals

 

es5678.PNG

What is “this” value in JavaScript?

In JavaScript a function’s this keyword value is –

  1. determined by how a function is called. 
  2. never static and has a different value depending on how the function was invoked.

Below are the this values in different execution context- 

  • Global Context– In the global execution context (outside of any function), this refers to the global object, whether in strict mode or not.
  • Function Context – If code is not in strict mode, and because the value of this is not set by the call, this will default to the global object- In strict mode, however, the value of this remains at whatever it was set to when entering the execution context, so, in the following case, this will default to undefined 
    So, in strict mode, if this was not defined by the execution context, it remains undefined.
  • Custom value- To pass this value from one context to another we can use call or apply functionsWhere a function uses the this keyword in its body, its value can be bound to a particular object in the call using the call or apply methods which all functions inherit from Function.prototype

Can not find element using id having special character in jQuery ?

If you have special characters (!”#$%&'()*+,./:;?@[\]^`{|}~) in your HTML element’s name or ID then it can not be find using jQuery find method.  You have to escape the character with two backslashes \\.

For example, if you have an element with id=”foo.bar”, you can use the selector $(“#foo\\.bar”)

// Does not work:
$( "#some:id" )
// Works!
$( "#some\\:id" )
// Does not work:
$( "#some.id" )
// Works!
$( "#some\\.id" )

 

 

 

Difference between SFTP and FTPS ?

SFTP and FTPS are secure file transfers protocols. Both offer a high level of protection since they implement strong algorithms such as AES and Triple DES to encrypt any data transferred. Most notable differences between SFTP and FTPS is how connections are authenticated and managed.

Authentication Differences-

  1. SFTP => FTP over SSH 
    • Connection can be authenticated via both credentials(UserID/Password) and SSH keys.
    • UserID/Password supplied in encrypted format over the SFTP connection.
    • While using key-based authentication, you will first need to generate a SSH private key and public key beforehand. While making connection send your SSH public key to them, which they will load onto their server and associate with your account. When you connect to their SFTP server, your client software will transmit your public key to the server for authentication. If the keys match, along with any user/password supplied, then the authentication will succeed.
  2. FTPS => FTP over SSL
    • Connection authenticated using a user id, password and certificate(s)
    • Like SFTP, the user id and passwords for FTPS connections will also be encrypted.
    • While making connection FTPS client will first check if the server’s certificate is trusted. The certificate is considered trusted if either the certificate was signed off by a known certificate authority (CA), like Verisign, or if the certificate was self-signed (by your partner) and you have a copy of their public certificate in your trusted key store.

 

 

References-

https://www.goanywhere.com/blog/2011/10/20/sftp-ftps-secure-ftp-transfers

What is Data Warehouse?

 

Data warehouse is a Warehouse of data. Place where all the data kept

In real time, it may be possible that a company or a business maintain their data via more than one system. Let’s takean example of an organization called ABC organization. It maintain Employee related information in Sql Server database, Client information in Excel, Sales and Purchase information is Oracle DB. Now information/knowledge generation  involves three steps.

  • Gathering data from all of these subsystems.
  • Applying some computation on all of these data – Data retrieved from each data source will be analysed for information and may be clubbed together.
  • Finally displaying them in an easy to understand format.


More the data is scattered more complex data retrieval becomes and more time will be taken to generation information/knowledge.

To solve this problem, industry identified a solution called Data warehouse. It’s going to be a simple database like Oracle, Sql or any other.

All the data maintained inside different sub systems in different format will be retrieved and converted into a common format and stored into this data warehouse. It became the first step in Business intelligence process. Data stored inside this Data Warehouse becomes source for the Information creation. Instead of analysing data in each data source, simply Data Warehouse data will be analysed.