Lukasz Lysik
Lukasz Lysik

Reputation: 10620

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.

Upvotes: 5

Views: 3913

Answers (2)

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93464

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.

Upvotes: 5

Ofer Zelig
Ofer Zelig

Reputation: 17508

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.

Upvotes: 0

Related Questions