Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does ASP.Net MVC differ from Classic ASP (not ASP.Net--the original ASP)

I'm trying to get a high-level understanding of ASP.Net MVC, and it has started to occur to me that it looks a lot like the original ASP script. Back in the day, we were organizing our "model"/business logic code into VBScript classes, or into VB COM components.

Of course, now we have the additional power of c# and the .net framework classes. Besides the high-level oo and other capabilities in c# and .Net, what are the other major differences between the original ASP and ASP.Net MVC?

like image 920
alchemical Avatar asked Mar 13 '10 00:03

alchemical


People also ask

What is difference between ASP.NET and ASP.NET MVC?

Asp.Net MVC has Partial Views for code re-usability. Asp.Net Web Form has built-in data controls and best for rapid development with powerful data access. Asp.Net MVC is lightweight, provide full control over markup and support many features that allow fast & agile development.

How is ASP.NET different from classic ASP?

ASP or also popularly known as Classic ASP developed by Microsoft is first Server-side scripting engine which is used for dynamic generation of web pages. ASP.NET, on the other hand, is a server-side web framework, open-source, which is designed for the generation of dynamic web pages.

What is the difference between MVC and ASP.NET MVC?

MVC (Model, View, Controller) is an Architect Pattern. ASP.NET MVC is an implementation of this pattern of Microsoft ASP.NET and you can use C#, VB.Net and other languages to programming on this platform.

Which of the following is a key difference between asp net webforms and ASP.NET MVC processing?

Webforms are MVC are two development styles available in ASP.NET. The difference between Webform and MVC is that the Webform follows a traditional event-driven development model while the MVC follows a Model, View, and Controller pattern based development model.

Which is better ASP.NET or ASP.NET MVC?

ASP.NET requires less expertise than MVC and is much faster to develop web applications overall. Prior knowledge of HTML is not required. ASP.NET uses a more mature code-base and has a larger web control toolbox. It's more sensible to use ASP.NET if you are already relying on 3rd party UI controls.


1 Answers

There are three main differences: URL mapping, separation of logic from presentation, and strong typing.

URL Mapping

With classic ASP there is a smooth transition from writing HTML pages to writing HTML pages with dynamic content. As with static HTML files, each URL has a direct mapping to a file in the filesystem. The same thing is more or less true of ASP.NET, for what it's worth.

In ASP.NET MVC, each "family" of URLs maps to a Controller object (stored in the /Controllers directory, by default), where each member of the family calls a method when accessed. At the end of each method (typically), you tell it to render a particular view (stored in a folder named after the controller in the /Views directory), which is a lot like a classic ASP page with all of the logic separated out.

This gives you logical and SEO-friendly URLs and groups related functionality together.

Separation of Logic from Presentation

In classic ASP it's common to find pages where a bit of HTML is included at the top, and then a database connection is opened and some things are read from the database while being output to the user, and then some more html, and then another database statement, and so on.

In ASP.NET MVC, your business logic (e.g. validation) goes in the model layer (you can choose from one of several dozen, but popular choices are LINQ-to-SQL and LINQ-to-Entity-Framework), your human interface logic goes in the controller (e.g. populating a State/Province menu based on the Country selection), and your presentation (the actual HTML you can hand to a designer to edit) goes in the view.

Aside from keeping things organized, this helps a great deal with being able to write automated tests for things. You can send a mocked-up object to your view and make sure it looks good, you can send bad data to your model and make sure it complains, and you can make sure that the object your controller sends out to your view is consistent with what it reads from the model.

Strong Typing and Compilation

ASP.NET is strongly typed and compiled. This is a double-edged sword. On the one hand, it will catch a lot of stupid programmer mistakes at compile time. On the other hand it, that means you're left with "infinity minus one" possible errors in your code (unit testing can make it infinity minus some larger number). Also, you'll have to do things like:

if (MyArray.Length > 0)

rather than

if (MyArray.Length)

But IMHO that's a small price to pay for the speed and sanity-checking you get from strong typing.

The bigger downside to compiled languages in a big framework is that deployment becomes much more of a production than it is with something like Classic ASP. You can't just copy a couple of files to the web server to update your app. You typically have to take the webserver down (hopefully you have a redundant pair) and recompile, which can take minutes.

like image 114
Frank Schmitt Avatar answered Nov 15 '22 12:11

Frank Schmitt