What is the difference between ASP.NET and ASP.NET MVC? - asp.net

I'm a complete beginner when it comes to ASP.NET but I want to learn it in order to build a web application that eventually will communicate with a cloud hosted SQL server. However, I cannot find any information that outlines the difference between ASP.NET web application and ASP.NET MVC2 web application (in visual studio 2010) so I'm not sure where to start. Can anyone give me a simple explanation/outline so I can decide on a tutorial to follow?
Thanks

ASP.NET is a web platform. It provides a layer that sits on top of IIS (the web server) which facilitates the creation of web applications and web services. ASP.NET MVC is a framework specifically for building web applications. It sits ontop of ASP.NET and uses APIs provided by ASP.NET. ASP.NET Web Forms is another framework specifically for building web applications, and the new ASP.NET Web API is a platform for building web services.

ASP.NET, at its most basic level, provides a means for you to provide general HTML markup combined with server side "controls" within the event-driven programming model that can be leveraged with VB, C#, and so on. You define the page(s) of a site, drop in the controls, and provide the programmatic plumbing to make it all work.
ASP.NET MVC is an application framework based on the Model-View-Controller architectural pattern. This is what might be considered a "canned" framework for a specific way of implementing a web site, with a page acting as the "controller" and dispatching requests to the appropriate pages in the application. The idea is to "partition" the various elements of the application, eg business rules, presentation rules, and so on.
Think of the former as the "blank slate" for implementing a site architecture you've designed more or less from the ground up. MVC provides a mechanism for designing a site around a pre-determined "pattern" of application access, if that makes sense. There's more technical detail to it than that, to be sure, but that's the nickel tour for the purposes of the question.
Good luck!

ASP.NET MVC2 web application is based on MVC pattern in order to facilitate unit test, without mocking pipeline asp.net, because it's very difficult. you don't have code on Code Behind in order to separate your code graphic and your code functional.
With MVC your application become independent from view. you can replace easily technology of creating view.
Read this article it's very interesting : http://msdn.microsoft.com/en-us/magazine/dd942833.aspx

If you have VS10 make a small ASP.NET (webforms) application and a small ASP.NET MVC 2 application, and examine the differences between them. It's a great way to learn.

A very good material is available here
http://www.webdevelopmenthelp.net/2013/10/Difference-between-ASP.NET-WebForm-And-ASP.NET-MVC.html

Like ASP.Net web forms, ASP.Net MVC is development model to build web application in Microsoft .net framework. The major difference between them are ASP.net MVC is based on the MVC architecture. Where we have 3 independent tiers – Model, View Controllers which interact which each other to render HTML output.
Major differences
Web forms is mainly has an event driven model. Where we have page level events(Page_load, pre render, page_init etc) and control level events. Which is not the case for MVC. The request life cycle is comparatively complex.(why complex because, the request has to goes through all the events before rendering the HTML output )
Web forms is basically has an aspx page which contains UI controls and a code behind file. All the page level events and control level events are handled here. In MVC the View, Model , controller can exist independently (gives clear separation of concern)
The SOC makes it easier for development as we can have separate developers for View(design html) and controller (implement business logic)
Because of this tight coupling nature, web forms are not suitable for unit tests. In MVC we can write unit tests at both controller level, action method levels. Here we can mock the data to be passed to view and do assert the result from the action method for their different properties like view name, model properties, null check etc
In web forms we have state full behavior. The server controls in ASPX page uses view state to retain their state during request response cycle. Since this view states are stored as hidden controls inside the page itself, and they are sent during request and response cycle, it makes them more heavy. Absence of view state and state less nature of MVC make it more light weight. Hence they are much more faster in request lifecycle.

ASP.NET is a web platform. It provides a layer that sits on top of the web server which facilitates the creation of web applications and web services. ASP.NET is a framework specifically for building web applications. It sits of ASP.NET and uses APIs provided by ASP.NET. ASP.NET Web Forms is another framework specifically for building web applications, and the new ASP.NET Web API is a platform for building web services

ASP.NET is a 2 tier application in which no separate section for the database and MVC is a 3 tier application in which view and logic is kept separate.
In ASP.NET for each .aspx form one URL is generated, but in MVC the url's are generated based on the controller and by the router configuration.

Related

Simple plain ASP.NET application example (without Web Forms and MVC)

For many developers ASP.NET and ASP.NET Web Forms are the same things. For some time I've been using Web Forms, but recently I learned that Web Forms is only build on top of ASP.NET. I become more curious how does a simple plain ASP.NET application look like. I learned about 3 ASP.NET programming models: Web Forms, Web Pages and MVC (Here Scott Hanselman explains briefly the differences). But it still seams that all the 3 approaches sits on top of ASP.NET.
I was trying to find an example application which uses pure ASP.NET, but I couldn't find anything.
I started to dig deeper into source code of ASP.NET web page and I found out that each web page is actually HTTP Handler (each page implements IHTTPHandler interface). Does it mean that pure ASP.NET application would be just a HTTP Handler implementation? Or am I missing something.
In my understanding ASP.NET Web Forms correspond to Win Forms in desktop world. But in the desktop world you can still write console application which doesn't use Win Forms. So what is an equivalent of console application in the web world?
Any comments or references appreciated. Thanks in advance.
ASP.NET is a very broad set of technologies, and it includes WebForms.. and as of MVC5, it also includes MVC, WebApi and WebPages. This is what Microsoft is now calling the "One ASP.NET" initiative.
These are all part of ASP.NET, just like ASP.NET is part of .NET. These are all just layers. There is no 'seperate' part called asp.net that does not contain these pieces (and even in earlier versions, there was no version of asp.net that did not include WebForms).
As such, there's no such thing as a "pure asp.net" app. You can certainly write an app that does not use WebForms (which means no .aspx or ascx or .master files, no Server Controls of any kind... essentially anything that exists in the System.Web.UI namespace.)
At most, you could consider this whatever is in the System.Web namespace (without any further levels of namespaces. Essentially what's here http://msdn.microsoft.com/en-us/library/system.web.aspx )
So that would be things like the Request object, the Response object, Cookie handling, Membership, FormsAuthentication, etc... This is basic plumbing that isn't all that useful by itself. You would have to write a presentation framework of your own to sit on top of it.
There are other frameworks out there, such as FubuMVC, Nancy, MonoRail, etc... these are just like MVC or WebForms or WebPages... using the basic ASP.NET classes to do their job.
I would like to refer you, as an example, to ASP.NET MVC.
ASP.NET MVC is a framework on top of ASP.NET but is definitely not Web Forms (in fact, it replaces it completely, and to my opinion - for the best).
ASP.NET provides services common to web in general, things such as:
Handling requests and responses
Security, Authentication, Impersonation etc.
Maintaining an 'Application' (the notion of Global.asax for example as a framework around instansiating apps, shutting them down, handling central things such as Routes, handling uncaught exceptions etc.)
Taking care of hosting permissions
Physical & virtual apps
Interfacing with IIS (or other web servers) in general
Running Modules (in addition to HTTP Handlers)
Web Forms adds a presentation layer on top of ASP.NET's infrastructure. It provides things such as Forms, ViewState and such. "Translating" code-behind code to HTML representation for example. This are just few examples.
The separation between ASP.NET as an infrastructure and Web Forms as a presentation layer allowed creating ASP.NET MVC later on. ASP.NET MVC does not rely on 'Forms' at all, does not try to mimic WinForms development workflows (by obscuring raw HTML using code-behind "methods" and "properties" and such) and in fact provides a much better & correct way to do web development.
You were asking about pure ASP.NET. Here is an example of pure ASP.NET, no WebForms, no MVC. Here is one: http://support.microsoft.com/kb/308001 . It's a basic HTTP Handler that, in this example, runs every time your browse to some address ending with .sync (by "teaching" ASP.NET to handle every request that uses that extension).
By the way, you can treat it as a "console" app (in your terms). It gets a URL, no matter where from (you can use curl if you like) and returns a text response, and that's all.

Confusion on using asp.net or mvc

Ive been confused about ASP.NET MVC.
As some said, MVC is better than ASP.NET. As some said, they are completely the same thing.
And my colleges debate that MVC is just an extension of asp.net, where asp.net is already in the form of MVC.
In fact I am starting web developing from scratch. If someone might help to clear the fog front of me, it would help a lot.
All ASP.NET web frameworks are build on top of Microsoft ASP.NET Framework. The unique feature of Web API is that it can be used with both MVC and WebForms applications to provide truly restful HTTP services.
Regarding the choice of suitable Asp.NET framework: you may get more information from official source - www.asp.net.
General rule of thumb is the architectural design how you want to build your application.
ASP.NET MVC promotes a cleaner separation which makes the developer think more in depth about design and code separation than traditional web forms.
There are endless debates about what is better but true benefits of ASP.NET MVC as
testability
more control over the rendered HTML
separation of concerns. However with MVC there is much more to learn for the developer.
ASP.NET WebForms - will always be around because some see it as a rapid application development tool. Just drag and drop and let ASP.NET handle the posting, state etc
ASP.NET Web API - is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
All in all, each of them has certain business solutions to be considered as required.
References to look for comparison:
ASP.NET MVC vs WebForms: speed and architecture comparison
ASP.NET Roadmap: One ASP.NET – Web Forms, MVC, Web API, and more
ASP.NET is the name of the overall web framework. There are a few different technologies that are built on ASP.NET. Two popular examples of these technologies are WebForms and MVC.
WebForms promotes a programming model that looks a lot more like Windows Forms. It attempts to abstract away the stateless nature of the web, and encourages you to use server-side controls instead of HTML. Because WebForms was the primary way to write web applications on ASP.NET for a long time before MVC came out, you'll often see people talk about "ASP.NET" as the same thing as WebForms. This is part of the reason for your confusion. ASP.NET WebForms is very different from ASP.NET MVC, but they are both built on ASP.NET.
ASP.NET MVC gets away from server-side controls. It eliminates the abstractions, allowing you to have closer control over the actual HTML that gets generated. For developers of modern applications, this is very useful because it makes it much easier to use AJAX and rich client-side javascript.
(Humble Opinion incoming)
ASP.NET (in terms of using Webforms) is programming the web for a WinForms developer. You "bind" events, you have "controls" and everything (sessionstate) is stored in a huge hidden field within the page so it knows where it left off from the previous call. You rely heavily on this information being present which is why everything you do needs to reside in that master form wrapping the entire page.
On the other hand, MVC is bringing C# .NET programming back to the web the way the web was intended. No bloat, no hidden fields, no heavy bindings. It's brings everything back to the classic "i have this form and now I need to process it". Arguably, the real magic is the routing methods and the "automatic binding" of submitted fields to an object. (if fields x, y & z are submitted and your action is looking for FooBar with the properties x, y & z it's automatically converted for you.
ASP.NET is common to both WEB-API and ASP.NET MVC. I assume you wonder about MVC or WEB-API.
MVC is a controller / model based with Views. Although the controllers can be used for AJAX json purposes. MVC is a good way to build a serious Browser based Application. The WEB-API allows you to build simple http server features, not necessarily Browser related. Good for REST style programming. Very flexible and a good alternative to WCF services. The are good tutorials on Both on the official ASP.NET site. START here http://www.asp.net/get-started
choose depends on your project n you. I suggest you to choose MVC because its productivity is very high we r using it since 1 year and found better than webforms.
for more knowledge please visit http://www.asp.net/mvc
The choice depends completely on you, I have been developing MVC application since 2010, its going to be over 2 years now have worked with almost all the versions of MVC both with Razor and aspx view. I have also worked on ASP.Net webform based applications.
With MVC you will not get built in controls, you will have to develop every control you want to use, you will have to rely mostly on html controls, while with web forms you will get advantage of using built in controls, Even getting help from other developers in your surroundings may be easy for webforms as you can easily get a webform developer.
But on the other hand with MVC the maintability is very high. As for as productivity is concerned, its very high once your are accustomed to it, initially it will be low as you will be in learning phase. Don't forget to use Entity Framework.
You may also consider developing your App using WebAPI, if it suits your scenario.

How Web page is a programming model to create ASP.Net web application

ASP.NET Web Forms is a part of the ASP.NET web application framework. It is one of the three different programming models you can use to create ASP.NET web applications, the others being ASP.NET MVC and ASP.NET Web Pages.
I have read above lines in asp.net site. My understanding is A web page may refer to a html document retrieved from server and A Web Form is a thing in ASP.NET Application used to generate a HTML document(in dynamic manner)
But definition of web forms said by asp.net site confused me. OK I can understand MVC is a programming model used to create ASP.NET Web application.
What is a Web Form ? and What is a Web page ?
How Web page is a programming model to create ASP.Net web application
ASP.Net is Microsoft's technology stack for building dynamic web sites.
Within that stack, they support 3 different ways of generating a web page.
Web Forms is the oldest - it's been around since ASP.Net was born. It's tightly coupled into Visual Studio, and has "drag and drop" page building. Most people who care about how their HTML is constructed dislike Web Forms, because the "drag and drop" components can make it hard to generate semantic, valid HTML - though the latest version is a lot better.
ASP.Net MVC is an alternative to Web Forms - and it's a pretty decent MVC framework.
Web Pages is another alternative; it's more of a scripting/templating solution, similar to PHP. It doesn't have the overhead/safetynet of a proper framework behind it (like MVC), and it uses RAZOR to support the view engine.
For any non-trivial new projects, ASP.Net MVC is the industry standard.

what is the difference between the asp.net mvc application and asp.net web application

can any one explain the difference between the mvc and web application in asp.net.
in mvc we can find controllers folder. cant we able to find controllers folder in web application..! please vanish my confusion.
MVC uses controllers to orchestrate the models and views to provide user interfaces to the user.
Web forms doesn't use controllers to achieve this, it uses code behind with events.
MVC is built around the notion of separation of concerns - each thing is responsible for its own bit, and shouldn't be concerned with what other bits are doing. Webforms has them a bit more mushed together, where code sits associated 1:1 with the webform (in the code behind), often leading to business logic creeping into the UI.
WebForms uses a powerful eventing system to help abstract away some of the complexities of HTTP, such as its stateless nature. MVC doesn't do this, which requires the developer to work within the confines of a pure HTTP environment. The eventing system in WebForms lets you quickly wire up events in a familiar way if you've come from a VB6/WinForms background (which the target audience had when ASP.NET was first released).
Have a look at http://www.asp.net/mvc which has a lot of great tutorials on getting started with MVC.
An ASP.NET MVC application is an application which depends upon the ASP.NET MVC Framework. MVC stands for Model, View Controller, the three components which define an application created using the MVC pattern.
The MVC pattern aims to seperate an applications logic, data and presentation into distinct, somewhat independent components.
Model
Models are a representation of an application's data. For example a shopping application might have a Cart model to represent the state of a user's shopping cart.
View
A view is a visual representation of the data contained in the model. A view class should knoow the specifics of how the model(s) it uses should be presented.
Controller
The Controller's job is to handle user input and update the state of the Model to reflect the changes that were made as a result of user action. For example imagine the user is viewing a Contact Us page and clicks the Submit button. The controller would respond to the button click by updating the model with values from the form fields and then save the model, causing it to be validated and then written to the database.
This is a very shallow and incomplete explaination of the MVC pattern you should head over to the ASP.NET MVC homepage to get a more complete view of the MVC pattern and the ASP.NET MVC framework.
An ASP.NET Web Application uses a separate framework known as Web Forms. Because Web Forms does not use the conventions defined in the MVC pattern, the Web Application template does not create a similar folder structure .
The use of either framework is not mutually exclusive, the two represent differing approaches to the same problem. With respect to which is most efficient for data access I would refere you to Michael Shimmins' excellent comment

ASP.NET MVC Web application vs ASP.NET Web Application

Other than the fact that ASP.NET MVC Web Application has more clarity in its implementation of the MVC pattern and that it strictly follows the MVC pattern, how is it different from ASP.NET Web Application?
If you make your ASP.NET Web Application have a Business Logic Layer, Data Access Layer and strictly make all data queries using them, then does'nt it completely follow the MVC pattern?
My logic here is: the BLL & DLL together is the Model, the ASPX page is the View and the code-behind (ASPX.CS) page is the Controller.
Thanks in advance to anyone who can confirm the above and/or shed more light on the subject.
This recent question may address your concerns: How does the MVC pattern differ, if at all, from the DAL / BLL design pattern?
It takes a bit more experience, discipline and work to design an ASP.NET MVP Web Application so that your application supports test automation. When you can slap an advanced GridView onto a page along with a SqlDataSource and bind it directly to a stored procedure you throw your test automation out the window.
A lot of MVP applications are written using 3rd party toolkits that encapsulate a lot of the codebehind logic. That tends to muck up your clean separation of responsibilities in a MVP design.
On the plus side I can write an ASP.NET Web Application with a rich UI using a 3rd party toolkit in a 10th of the time I can with MVC in it's current state. For a simple admin tool that's exactly what I would do today. For a large scale n-tier application I would lean towards MVC.

Resources