Is ASP.Net MVC always the best choice?

I’ve always mentioned in my articles, that many of the ASP.Net developers have little information about web pages structure. Because they have a POWERFUL tool named Visual studio!

“Web”, in one sentence is consist of a web page that is transferred between the client and the server. Those developers who have just used ‘Web Forms’ (this abomination!) , have no idea what is going behind the scene. They do know nothing of the web mechanism.

Those who just know Asp.Net MVC, suffer the same problem. Of course the logic behind MVC is way better than ‘Web forms’ but still can lead to misunderstanding if you are not familiar with web structure.

But what is this “Web Structure”

Web is all about transferring a page between the client and the server. The server job is to send a “page” as a the result of a request. But what is this request?

Whenever you type a URL address in your browser and hit the “enter” button, You call a server!

You write an address that leads to a server machine and ask this machine to send you a page.

This page is consist of some HTML,CSS and Javascript. Nothing more.

The browser shows that Codes, as a graphical document. Then you make some changes, This changes are sent to the server machine again. The server reads them and react!

But how? There is no magic. Every HTML tag, (take a text Input as an example) has an attribute which is called “NAME”. And every tag has a value. What happens in the background is that The server reads the html page and whenever it hits a “NAME” attribute, The server reads the assigned value. So there is nothing but a list of key-values. That is what server sees!

Lets give you an example: You type: “” into the browser address bar. In fact that URL is assigned to a server machine IP. This IP is valid. Thus this URL leads to an IP and that IP leads to a machine.

As you call this machine and make a request, It sends you and HTML page as the answer.

This HTML page has a Search Input which lets you search the site. This input is inside a “Form” tag. That input has a “Name” attribute. Lets say it is called “txt-search”.

So as you send back the page to the server by the submit button, The server gets the page. Reads it. Extracts the “txt-Search” value out of it and make proper query, gets result from database, convert it to html and send it back to you!

So where the hell is all that Event,Validation,model, view state etc that exists in Web Forms and MVC? The answer is: “There is nothing like that in the world of web!!!”.

All that you see is created by mixing java script and server side languages!

So now you get it better that MVC is not a language! it is just a pattern. A pattern which is based on Web pages 2.

But What is WebPages2?

Web pages 2 is an standard based on It is in fact a coding standard which has mixed Razor and ASP and other technologies together. MVC is just a wrapper on this standard.

The “@code” syntax that you use in MVC is in fact a part of this standard! Like php, You can use this standard, Without using MVC. It is page based. meaning you can write your codes in a “@{//code}” block and put it into a “.cshtml” page. Then you can add html codes into it as well. Just it! not publish it on IIS and call the page! Of course you will need some extra DLLs.

Speaking of Dlls, I should tell you that all those folders we use in .net web sites(such as app_code and app_data) are there as standard folders of

For example, It is accepted and standard to put .cs classes into the app_code folder and call them through there.

So What are other options?

have you ever noticed that in Visual Studio, You can either use File=>New=>Web site

or you can use File=>New Project=>New Web Project

The first one creates a raw Web Pages web site. But the second one creates a site and wraps it with some technologies which makes it like an application. This way you can code without being worry of basic information of how your code works! And that is the exact point. All those automatic processes(which are somehow good too) lead you into “not knowing what is happening” world!

Of course I do not mean you shall not use these technologies. In fact if you do not use them, You are a fool! My point is that it will be so good if before hitting the “new MVC Project” button, We try the understand what is going behind the scene.

Next time you wanted to create a small business website, consider taking a look at “New Website” too!

Leave a Reply

Your email address will not be published. Required fields are marked *