Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Not Enjoying ASP.Net

After a couple of years away from web development, I'm getting back in and learning ASP.net.  Previously I worked with old style ASP, where each file was a mishmash HTML, Javascript, css and vbscript, with calls to com objects to get the heavy work done.  Everyone agrees this was a mess.

Then I did some java work, where jsp looked a lot like asp, except everything was compiled.  As an alternative, you could go with servlets for things that were more like applications than web pages i.e. the dynamic part was much larger that the static part.  For the things I was doing, I much prefered servlets.

Coming to ASP.Net, I would like to use a servlet type approach, but take advantage of some of the things ASP.Net gives, like the automatic loading of controls on posts, and maybe databinding - to objects, not database tables. I love dot net and have written quite a bit of C# code that I want to reuse in this project.   

But it seems like ASP.net forces you into this JSP-like scheme where you have your layout in one file, and you "page logic" in a separate "code-behind" file.  I appreciate what they are trying to do, and I suppose it is an advance over old ASP, but I'm not comfortable with it

I need to have things layered like this:

1) Domain objects that interact with the database, and are resusable in a non-web context.
2) Servet-like classes that use the domain objects to produce XHTML
3) css files for layout and appearance.

The ASP.Net documentation I've seen doesn't emphasise layers 1 and 3, but I don't see any reason why I can't structure things that way.  My bigger problem is layer 2, where it seems to force you into spliting your code into  VS generated (but editable) templated html and code behind.  To me this is a step backward because I lose some control of what the HTML looks like, and I have to contend with the extra complications of how the aspx and the code behind work together.

A friend told me to just "get over it" - that is how asp.net works and I should just adjust.  I'm I the only one who sees things this way?  Can anyone point me to a book/blog/article that can give me some guidance. 
       

 




   

   

ASP.Net Noob
Thursday, January 20, 2005

ASP.NET does work in the way you describe, at least that is how I use it.

In my case, the ASP.NET "page" is just blank and the C# classes do all the work by overriding the Page methods, OnLoad, Render, etc.

In this way, the C# code fetches the data, builds the (X)HTML and renders it to the page.

Nemesis
Thursday, January 20, 2005

The ASP.NET Starter Kits are good code samples doing just what you describe.  Take a look at the Issue Tracker starter kit:

http://www.asp.net/Default.aspx?tabindex=8&tabid=47

anon
Thursday, January 20, 2005

Thanks anon - I'll start looking into Issue Tracker.

ASP.Net Noob
Thursday, January 20, 2005

"But it seems like ASP.net forces you into this JSP-like scheme where you have your layout in one file, and you "page logic" in a separate "code-behind" file. "

Definetely encourages you, but does NOT force you. Examples of everything in one file are all over the place.

NetFreak
Friday, January 21, 2005

You don't need the ASPX file at all.

Just write a class that inherits from Page as you normally would. The only trick is to hook it up using web.config. Search for "Registering HttpHandlers" on MSDN. (Page inherits from IHttpHandler, so your class is an http handler too.)

Active CM
Friday, January 21, 2005

I have an article that talks about handlers in .NET:

http://www.dotnetdevs.com/articles/IntroToHandlers.aspx

Since I peruse the boards, feel free to ask questions. :)

Brad Wilson (www.dotnetdevs.com)
Tuesday, January 25, 2005

Take a look at HTTPHandlers and Modules.  These almost exactly the same implementation as in Java and can be used in exactly the same way.

You should also look into products like Maverick for .Net.  This is a great framework that is fairly easy to use and allows you to specify controllers (servlets) very much like struts but without all the added features you might not need anyway.

Tom Brune
Thursday, February 10, 2005

Nemesis, unless you have an extremely good reason for doing so, thats a horrible design. 

Vince
Saturday, February 12, 2005

*  Recent Topics

*  Fog Creek Home