Wednesday, 22 October 2014

What is the difference between iisreset, recycle, refresh and restart?

iisreset

iisreset will stop and start the World Wide Web Publishing Service. This, of course, applies to all of your application pools.

Recycle application pool

A process being created for each application pool. This process will handle requests for all websites associated with it. When you recycle an application pool, IIS will create a new process (keeping the old one) to serve requests. Then it tries to move all requests on the new process. After a time-out the old process will be killed automatically.

You usually recycle your application pool to get rid of leaked memory. You might have a problem in your application if this needs to be a regular operation. It is recommended to have a scheduled recycle.

Restarting a website

As for restarting a website, it just stops and restarts serving requests for that particular website. It will continue to serve other websites on the same app pool with no interruptions.

If you have a session oriented application, all of the above will cause loss of session objects.

Refreshing IIS or a website

Refreshing a website has no effect on the service/process/website and is merely a UI command to refresh the tree-view. For example you have added a directory that you don't see in the management console. Then refreshing the website will show the new directory in the treeview.

Tuesday, 21 October 2014

Difference between jQuery.bind() and jQuery.on()?

.on() is a new function available from jQuery version 1.7. .on() can be used to attach an event handler function for one or more events of the selected elements.

The .on() method provides all functionality required for attaching event handlers. So on() is now preferred over other event handling functions .bind(), .delegate() and .live()

Syntax
.on( events [, selector ] [, data ], handler )
Notes

To remove events bound with .on() use .off(). To attach an event that runs only once and then removes itself use .one()

on() vs bind()

These two lines are functionally the same

    $( '#element' ).bind( 'click', handler );
    $( '#element' ).on( 'click', handler );

.on() can also do event delegation, and is preferred.

.bind() is actually just an alias for .on() now. Here's the definition of the bind function in 1.7.1.

    bind: function( types, data, fn ) {
    return this.on( types, null, data, fn );
    }

Friday, 10 October 2014

How to render partial view from different folder?

The usual syntax to render a partial view is

@Html.Partial("partialViewName")

This syntax expects the partial view to be physically present in the current folder or in the "Shared" folder.

If you want to use a partial view which is not in "Shared" but in a different "Views" folder then use below Razor syntax.

@Html.Partial("~/Views/AnotherFolder/_partialView.cshtml")

How to check for null, undefined, or blank variables in JavaScript?

You can just check if the variable has a true value or not. That means

if( value ) {
}

will evaluate to true if value is not:

  • null
  • undefined
  • NaN
  • empty string ("")
  • 0
  • false

Furthermore, if you don't know whether a variable exists (that means, if it was declared) you should check with the typeof operator. For instance

if( typeof foo !== 'undefined' ) {
    // foo could get resolved and it's defined
}

If you can be sure that a variable is declared at least, you can directly check if it has a true value.

Truth, Equality and JavaScript

JavaScript Coercion Demystified

Wednesday, 1 October 2014

Hashing, MD5, SHA1, Salted Password Hashing

Hashing

Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string. Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value. It is also used in many encryption algorithms.

A hash function is any function that can be used to map digital data of arbitrary size to digital data of fixed size, with slight differences in input data producing very big differences in output data.

Hash algorithms are one way functions. They turn any amount of data into a fixed-length "fingerprint" that cannot be reversed.

Collision / Hash Collision

The hash function is used to index the original value or key and then used later each time the data associated with the value or key is to be retrieved. Thus, hashing is always a one-way operation. There's no need to "reverse engineer" the hash function by analysing the hashed values. In fact, the ideal hash function can't be derived by such analysis. A good hash function also should not produce the same hash value from two different inputs. If it does, this is known as a collision.

MD5

The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.

SHA1

SHA1 stands for Secure Hash Algorithm makes a larger (160-bit / 20-byte) message digest and is similar to MD4. A SHA-1 hash value is typically rendered as a 40 digits long hexadecimal number.

Password Hashing

Hashing is great for protecting passwords, because we want to store passwords in a form that protects them even if the password file itself is compromised, but at the same time, we need to be able to verify that a user's password is correct.

The general workflow for an account registration and authentication in a hash-based account system is as follows:

  1. The user creates an account.
  2. Their password is hashed and stored in the database. At no point is the plain-text (unencrypted) password ever written to the hard drive.
  3. When the user attempts to login, the hash of the password they entered is checked against the hash of their real password (retrieved from the database).
  4. If the hashes match, the user is granted access. If not, the user is told they entered invalid login credentials.
  5. Steps 3 and 4 repeat everytime someone tries to login to their account.

In step 4, never tell the user if it was the username or password they got wrong. Always display a generic message like "Invalid username or password." This prevents attackers from enumerating valid usernames without knowing their passwords.

It should be noted that the hash functions used to protect passwords are not the same as the hash functions you may have seen in a data structures course. The hash functions used to implement data structures such as hash tables are designed to be fast, not secure. Only cryptographic hash functions may be used to implement password hashing. Hash functions like SHA256, SHA512, RipeMD, and WHIRLPOOL are cryptographic hash functions.

Salted Password Hashing

We can randomize the hashes by appending or prepending a random string, called a salt, to the password before hashing.The salt does not need to be secret. Just by randomizing the hashes, lookup tables, reverse lookup tables, and rainbow tables become ineffective. An attacker won't know in advance what the salt will be, so they can't pre-compute a lookup table or rainbow table. If each user's password is hashed with a different salt, the reverse lookup table attack won't work either.

Salted Password Hashing - Doing it Right

Friday, 26 September 2014

Is CSS case sensitive?

CSS is case insensitive in all matters under its control; however, some things, such as the document markup language, are beyond its control. HTML is case insensitive in most respects, except when it comes to certain attribute values, like the id and class attributes. XHTML, being XML, is always case sensitive.

The simplest way to mitigate any potential issues surrounding case sensitivity is to always use lowercase for everything in your markup and CSS, where possible. If that’s not possible, make sure the case you use is consistent between your CSS and your document markup.

CSS Case Sensitivity

www.w3.org >> Element identifiers: the id and class attributes

Are class names in CSS selectors case sensitive?

Wednesday, 24 September 2014

How does browsers' same-origin policy (SOP) work?

Browser security prevents a web page from making AJAX requests to another domain. This restriction is called the same-origin policy, and prevents a malicious site from reading sensitive data from another site. However, sometimes you might want to let other sites call your web Service / Web API.

I was under the impression that the request will never go to the server in this scenario. I am sure that many of you would be thinking the same. BUT if you watch the HTTP traffic in a tool like Fiddler, you will see that the browser does send the GET request, and the request succeeds, but the AJAX call returns an error. It’s important to understand that same-origin policy does not prevent the browser from sending the request. Instead, it prevents the application from seeing the response.

Now you can use a mechanism called CORS i.e Cross-Origin Resource Sharing, to enable client-side cross-origin requests.

Cross-Origin Requests in ASP.NET Web API

Cross-Origin Requests in ASP.NET Web API

Browser security prevents a web page from making AJAX requests to another domain. This restriction is called the same-origin policy, and prevents a malicious site from reading sensitive data from another site. However, sometimes you might want to let other sites call your web API.

Cross Origin Resource Sharing (CORS) is a W3C standard that allows a server to relax the same-origin policy. Using CORS, a server can explicitly allow some cross-origin requests while rejecting others. CORS is safer and more flexible than earlier techniques such as JSONP. Follow below links to see how to enable CORS in your Web API application.

Wednesday, 25 June 2014

Calculate execution time for a method

When you do performance optimization or something similar you will need to determine the execution time for a particular method call or a piece of code. Here is some code that you can use in those scenarios. Either StopWatch or DateTime can be used to do this.

Using System.Diagnostics.Stopwatch


Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();

// Your code, it could be in-line code, a web service call or whatever code you want to analyse, goes here

stopWatch.Stop();

// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;

// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);

Console.WriteLine("Time taken : " + elapsedTime);

// Or you can just call ToString() on TimeSpan var "ts"

Console.WriteLine("RunTime " + ts.ToString());

Using DateTime

DateTime start = DateTime.Now;

// Your code, it could be in-line code, a web service call or whatever code you want to analyse, goes here

DateTime end = DateTime.Now;

TimeSpan ts = end - start;

Console.WriteLine("Time taken : " + ts.ToString());

Free .NET decompiler

ILSpy

ILSpy is a free .Net decompiler.

ILSpy requires the .NET Framework 4.0.

Click here to download

Wednesday, 18 June 2014

How to detect IE11 from User Agent?

Pre-IE11 versions of Internet Explorer browser have a common pattern/string i.e. "MSIE" within their user agent string. But that is not the case with IE11.

IE11 user agent string

Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko

IE10 user agent string

Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)

Here is some JavaScript code to identify the version Internet Explorer from user agent string


var isIE11 =  navigator.userAgent.match(/Trident.*rv\:11\./);

var isIEButNotIE11 =  navigator.userAgent.match(/MSIE (\d+\.\d+)/);

This function can be used to get the version number of IE

function IEVersion() {

    var ieversion;

    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
        ieversion = new Number(RegExp.$1);
    else if (navigator.userAgent.match(/Trident.*rv\:11\./))
        ieversion = 11;

    return ieversion;
}

What is My User Agent?

I found this website today while I was looking for differences between User Agent value of IE11 and other older versions of IE.

http://www.whatsmyuseragent.com/

When you open the website it will display your user agent string and IP address as well.

Thursday, 29 May 2014

How to create a blank solution in Visual Studio?

Follow these steps to create an empty solution in Visual Studio
  1. On the File menu, click New and then click New Project.
  2. In the left pane, select Installed, select Other Project Types, and then select Visual Studio Solutions from the expanded list.
  3. In the middle pane, select Blank Solution.
  4. Set the Name and Location values for your solution, then click OK.

Monday, 19 May 2014

X-Frame-Options response header

The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <frame>, <iframe> or <object> . Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.

Using X-Frame-Options

There are three possible values for X-Frame-Options:

  • DENY

    The page cannot be displayed in a frame, regardless of the site attempting to do so.

  • SAMEORIGIN

    The page can only be displayed in a frame on the same origin as the page itself.

  • ALLOW-FROM uri

    The page can only be displayed in a frame on the specified origin.

Read More>>

What is clickjacking?

What is Clickjacking and How can you prevent it?

Modifying multiple CSS properties in one go using jQuery

jQuery .css() method can be used to set one or more CSS properties for every matched element.

Setting single CSS property
 
$('p').css( "background-color", "yellow" );

 

Setting multiple CSS propertes
 
$('div.header').css({"background-color": "yellow","font-weight": "bold" });

 

Read More

jQuery API - .css() Method

www.w3schools.com >>jQuery - css() Method

Thursday, 8 May 2014

Accessing radio button state using jQuery

You can use the .is(selector) function in jQuery to get the state of a radio button.

Example:

$("#radiobuttonid").is(":checked")

$('input[id="group1"]').is(':checked') 

Also

$("#radiobuttonid").attr("checked", true)
sets the state of the radion button to selected.

Monday, 5 May 2014

ASP.NET MVC Versions and Features

ASP.NET MVC1

Released in Mar 2009, Runs on .Net 3.5 / Visual Studio 2008, WebForm View Engine, Html Helpers, Ajax Helpers, Routing, Unit Testing

ASP.NET MVC2

Released in Mar 2010, Runs on .Net 3.5 / Visual Studio 2008 & .Net 4.0 / Visual Studio 2010, Strongly typed Html Helpers i.e. lambda expression based Html Helpers, Data Annotation Attributes, Client-side validation, UI helpers with automatic scaffolding & customizable templates, Attribute-based model validation on both client and server, Asynchronous controllers

ASP.NET MVC3

Released in Jan 2011, Runs on .Net 4.0 / Visual Studio 2010, Razor view engine, ViewBag dynamic property for passing data from controller to view, Global Action Filters, Better JavaScript support with unobtrusive JavaScript, jQuery Validation, and JSON binding, Improved Support for Data Annotations, Remote Validation, Compare Attribute, Partial-page output caching, Sessionless Controller, Child Action Output Caching, Dependency Resolver, Entity Framework Code First support, Use of NuGet to deliver software and manage dependencies throughout the platform, Good Intellisense support for Razor into Visual Studio

ASP.NET MVC4

Released in Aug 2012, Runs on .Net 4.0, 4.5 / Visual Studio 2012, ASP.NET Web API, Enhancements to default project templates, Mobile project template using jQuery Mobile, Display Modes, Task support for Asynchronous Controllers, Bundling and minification, Support for the Windows Azure SDK

ASP.NET MVC5

Released in Oct 2013, Runs on .Net 4.5, 4.5.1 / Visual Studio 2013, ASP.NET Web API2, One Asp.Net, Asp.Net Identity, ASP.NET Scaffolding, Authentication filters - run prior to authorization filters in the ASP.NET MVC pipeline, Bootstrap in the MVC template

Click here to read about C# Versions and features

Using ViewBag in _ViewStart.cshtml

Trying to set or get some value to/from ViewBag in _ViewStart.cshtml will throw an error when you run the app. There is a workaround for this using ViewContext.Controller.ViewBag.

Here is some sample code

ViewContext.Controller.ViewBag.StoreName = "My New Store";

...

@ViewContext.Controller.ViewBag.StoreName

Read more >>

ViewData mechanics and segmentation

Wednesday, 2 April 2014

what is the purpose of _viewstart.cshtml in ASP.NET MVC?

The _ViewStart.cshtml file will execute at the start of each view's rendering. Any code contained within the code block in this file will execute before any code in the view. Typically, this file will set the layout template to be used by the views in the application:

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

The _ViewStart file can be used to define common view code that you want to execute at the start of each View’s rendering. So we can optionally make our Layout selection logic richer than just a basic property set,if required.

Because this code executes at the start of each View, we no longer need to explicitly set the Layout in any of our individual view files (except if we wanted to override the default value above).

An MVC application can have multiple _ViewStart.cshtml files. The order in which these files execute is dependent upon the location of the files in the folder hierarchy and the particular view being rendered. The MVC Runtime will first execute the code in the _ViewStart.cshtml file located in the root of the Views folder. It will then work its way up the folder hierarchy, executing the code in each _ViewStart.cshtml file it finds along the way. For example, if we had_ViewStart.cshtml files in the following locations:

1) Views\_ViewStart.cshtml
2) Views\Home\_ViewStart.cshtml
3) Views\Products\_ViewStart.cshtml

When a view in the Views\Home folder is rendered, the MVC Runtime will first execute the code in file 1 and then execute the code in file 2. Since file 3 is not in the hierarchy of the Views\Home folder, the code in file 3 will not get executed.

Visual Studio 2012 - class names lost default colour and appear in black

Recently some settings on my Visual Studio 2012 got changed somehow and I lost most of the default colour settings in the IDE text editor for C#. Also "User Types" was missing from "Display items" list of "Tools > Options > Environment > Fonts and Colors" dialog box. So I was unable change the colour manually. I managed to bring back the default settings by doing the following.

  1. Delete folders
    • %appdata%\Roaming\Microsoft\Microsoft Visual Studio
    • %appdata%\Roaming\Microsoft\VisualStudio
    • %appdata%\Local\Microsoft\VisualStudio
    • My Documents/Visual Studio 2012/Settings
  2. Open Visual Studio 2012 command prompt (as administrator) and run
    • devenv.exe /setup
    • devenv.exe /ResetSettings
    *devenv.exe location is usually something like C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE.
I think the first step is irrelevant. So if you experience this problem I would suggest you skip step#1 and just follow step#2.

References

no-intellisense-no-indentation

class-names-not-coloured-in-visual-studio

how-can-i-get-user-type-c-sharp-syntax-highlighting-working-again

Monday, 31 March 2014

Passing date value as a string to JavaScript Date() object

Date() Constructor has following variations

new Date();
new Date(value);
new Date(dateString);
new Date(year, month [, day, hour, minute, second, millisecond]);

Date constructor parameters

Note: Where Date is called as a constructor with more than one argument, if values are greater than their logical range (e.g. 13 is provided as the month value or 70 for the minute value), the adjacent value will be adjusted. E.g.  new Date(2013,13,1) is equivalent to new Date(2014,1,1), both create a date for 2014-02-01 (note that the month is 0-based).
value

Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC.

dateString

String value representing a date. The string should be in a format recognized by the Date.parse() method (IETF-compliant RFC 2822 timestamps and also a version of ISO8601). Date.parse()

The parse method takes a date string (such as "Dec 25, 1995") and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC. This function is useful for setting date values based on string values, for example in conjunction with the setTime() method and the Date object.

Date.parse() understands the continental US time-zone abbreviations, but for general use, use a time-zone offset, for example, "Mon, 25 Dec 1995 13:30:00 +0430" (4 hours, 30 minutes east of the Greenwich meridian). If you do not specify a time zone, the local time zone is assumed.

<script>
alert(new Date("March 18, 2014"))
alert(new Date("March 18, 2014 00:00:00 +0430"))
alert(new Date("18 March 2014"))
alert(new Date("2014-03-18"))
</script>

year

Integer value representing the year. Values from 0 to 99 map to the years 1900 to 1999.

month

Integer value representing the month, beginning with 0 for January to 11 for December.

day

Integer value representing the day of the month.

More info

Date Object

Date.parse

JavaScript Dates

Wednesday, 26 March 2014

CSS3 word-break and word-wrap properties

word-break

Normally, line breaks in text can only occur in certain spaces, like when there is literally a space or a hyphen. When you set word-break to break-all, line breaks can occur between any character. Resulting in, for example:

Perform
ance

(if that word wouldn't quite fit into its parent container width)

Syntax
  word-break: normal | break-all | keep-all;
Example
p {
  word-break: break-all;
}

It's often used in places with user generated content so that long strings don't risk breaking layout. One very common example is a long copy and pasted URL. If that URL has no hyphens, it can extend beyond the parent box and look bad or worse, cause layout problems.

Read about word-break on w3schools.com

Read about word-break on css-tricks.com

word-wrap

Allow long words to be able to break and wrap onto the next line:

Syntax
word-wrap: normal|break-word|initial|inherit;
p.test {word-wrap:break-word;}

Read about word-wrap on w3schools.com

Friday, 21 March 2014

What is the difference between DIV and SPAN?

div is a block element, span is inline. This means that to use them semantically, divs should be used to wrap sections of a document, while spans should be used to wrap small portions of text, images, etc.

Tuesday, 25 February 2014

Useful addons for FireFox

FireBug

FireBug allows you to inspect, edit and monitor HTML, CSS and JavaScript in real-time.

http://getfirebug.com/

TabMixPlus

TabMixPlus has an option to display tabs in multiple rows when they don't fit in available width.

It includes features such as duplicating tabs, controlling tab focus, tab clicking options, undo closed tabs and windows, plus much more.

http://tmp.garyr.net/

FiddlerHook

Integrate Fiddler into FireFox

The FiddlerHook Firefox add-on points Firefox at Fiddler, avoiding the need for manual configuration or restarting Firefox.

https://www.fiddler2.com/redir/?id=FIDDLERHOOKHELP

http://docs.telerik.com/fiddler/KnowledgeBase/FiddlerHook

YSlow

YSlow analyses webpages and suggest ways to improve their performance.

Provides tools for performance analysis, including Smush.it™ and JSLint.

http://developer.yahoo.com/yslow/

PageSpeed

Similar to YSlow PageSpeed is a performance diagnostics tool.

Requires FireBug

https://developers.google.com/speed/pagespeed?csw=1

Friday, 21 February 2014

Useful add-ons for Google Chrome

AdBlock

AdBlock for Chrome! Block all advertisements on all web pages, even Facebook and Youtube.

Google Store link

Awesome Screenshot

Capture the whole page or any portion, annotate screenshot, blur sensitive info, one-click upload to share.

Google Store link

UA spoofer / User-Agent Switcher

Spoofs & Mimics User-Agent strings

Handy if your are developing a site that needs to work on both mobile browsers and desktop browsers.

Google Store link

CSSScan

Offers a quick overview of CSS properties to the element the mouse cursor is hovering.

Google Store link

measureit

Draw out a ruler to get the pixel width and height of any elements on a webpage

Google Store link

Resolution Test

An extension for developers to test web pages in different screen resolutions, with an option to define your own resolutions.

Google Store link

Responsive Site View

View responsive websites at the dimensions of real device screens, capture screenshots for your portfolio.

Google Store link

Tuesday, 18 February 2014

Useful jQuery plugins

Colorbox

A lightweight customizable lightbox plugin for jQuery.

Supports photos, grouping, slideshow, ajax, inline, and iframed content.

http://www.jacklmoore.com/colorbox/

Colorbox FAQs

jqTransform

This plugin allows you to skin form elements.

http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/

News Ticker

Taking inspiration from the BBC News website ticker, jQuery News Ticker brings a lightweight and easy to use news ticker to jQuery.

http://www.jquerynewsticker.com/

Unslider

The jQuery slider that just slides.

Use any HTML in your slides, extend with CSS. You have full control.

Supports dot navigation.

http://unslider.com/

ListNav

Add a letter-based navigation widget to any UL or OL list.

An easily stylable (via CSS) nav bar appears above the list, showing the user the letters A-through-Z.

Clicking one of the letters filters the list to show only the items in the list that start with that letter.

Batch files to stop and start IIS

Copy below commands to notepad and save as "IISStop.bat"

iisreset /stop
pause

Copy below commands to notepad and save as "IISStart.bat"

iisreset /start
pause

Double click on the file to run it. But you may get below error.

"Access denied, you must be an administrator of the remote computer to use this command. Either have your account added to the administrator local group of the remote computer or to the domain administrator global group."

In this case right click on the file and choose "Run as administrator".

What does iisreset do?

When you use iisreset command, the IIS Admin Service, the Windows Process Activation Service (WAS), and the World Wide Web Publishing Service (WWW Service) are stopped and restarted.

  • IISReset stops and restarts the entire web server.
  • Recycling an app pool will only affect applications running in that app pool.
  • Editing the web.config in a web application only affects that web application.
  • Editing the machine.config on the machine will recycle all app pools running.
  • IIS monitors the /bin directory of your application. Whenever a change is detected in those dlls, it will recycle the app and re-load those new dlls. It also monitors the web.config & machine.config in the same way and performs the same action for the applicable apps.

Where is the IIS Admin Service in IIS 7?

IIS Admin Service in not required in IIS 7 for as long as you are not using IIS Metabase compatibility feature or FTP 6 publishing services.

The interesting fact is that IIS can run without IIS admin service, Click here for the details.

Useful links

What does iisreset do?

Where is the IIS Admin Service

What does iisreset do?

How to stop batch files from closing automatically?

Usually a batch file auto-closes after processing the commands. But if you want to stop this behaviour then add a "pause" command at the end of the file.

pause DOS command

This prints "Press any key to continue . . . " message and waits for a key stroke.

Click on below links for more info

Batch files

Change output of pause command

List of DOS commands

RenderSection method in MVC3

You define the section in a view and render it in _Layout.cshtml. Section can contain any code that you normally put in a view, i.e. HTML, CSS or JavaScript or a combination of them.

RenderSection can only exist in Layout files i.e. master pages. If you want make a section that is reusable on many pages then you should go for a partial view.

Defining a section
@section Footer{
<p>This message is for Footer.</p>
}
Referencing a section
@RenderSection("Footer",false)
The second parameter is a boolean and specifies whether it is a required section or not.

Try below urls for more information

Layouts and sections with razor

RenderBody, RenderPage and RenderSection methods in MVC

Wednesday, 15 January 2014

How your web browser requests and receives a resource from a Web Server?

Your Web browser, in fact any web client, goes through the following cycle when it communicates with a Web server:

  1. Obtain an IP address from the IP/domain name of the site (the site URL without the leading 'http://'). This lookup (conversion of IP name to IP address) is provided by domain name servers (DNSs).
  2. Open an IP socket connection to that IP address.
  3. Write an HTTP data stream through that socket.
  4. Receive an HTTP data stream back from the Web server in response. This data stream contains status codes whose values are determined by the HTTP protocol. Parse this data stream for status codes and other useful information.

Click here to read more about HTTP status codes