Logo




Subscribe:
RSS 2.0 | Atom 1.0
Categories:

Sign In


[Giagnocavo]Michael::Write()

 Tuesday, October 12, 2004
Why do we lose the ASP.NET 1.x compilation model in ASP.NET 2?

Writing the Turing ASIX brought me back to a really sore spot in ASP.NET 2: Lack of a good compilation model. In ASP.NET 1.x, you could compile all your code (*.cs) into an assembly, and you were set. Here's why I hate the new “code-beside” and “dynamic compilation” models as they are implemented in VS 2005:

--Deployment/content editing nightmare
Before, I could drop the DLL on the server, *have no source code* on the server, and allow someone else (i.e., my client), to edit the ASPX/ASCX content. In a few cases where I wanted to expose code to him, I could make a virtual method in the base class, and allow him to override it via C# code in a <SCRIPT> block. With the new VS 2005 model, my scenario is blown away and destroyed.

--Access to code means huge, ugly, hackish workarounds
Before, if I made a page/class/control/whatever in any part of my app, I could reference this from any other part. For instance, my Turing image generator. I have two statics on it that any page can call. I want that code to be in Turing.asix.cs (or in the .asix). But I can't! I am required to put it in the /Code directory for no reason at all. Maybe this was done because of the “web programmers” who think HTML is a programming language. Maybe it was to act as a ward to scare of people who are afraid of code. I can't figure it out. All I know is that it pisses me off. This problem is more serious than just my annoyance about moving one file.

Suppose I'm working on a larger site, and to keep things in line, I organize the site into various folders. Now say I'm in something like /TheSite/SomeArea/HierarchialViews. I have a few ASCX controls there, but they all share some common code (some enums, and some pure code classes that help with the sorting or organization for the views (say, something that generates a generic tree to be consumed). Where do I put the code? Well, with this new model, I've got to put it in /TheSite/CODE/SomeArea/HierarchialViews. In other words, I'm required to duplicate my entire site organization inside the Code directory, just because... um, well, I haven't found a decent reason yet.

The ASP.NET/VWD/whatever team should NOT be making these kinds of decisions for developers. Visual Studio should be a tool that we can use to write apps how we want to write them. This model worked fine for 1.x. Why has it become so hideous that they needed to REMOVE it from 2.0? With all the huge advances ASP.NET 2 and VS2005 take, why must they take this big jump backwards? Couldn't they just leave it in and say “You can do this, but we really recommend using a Code folder so you don't lose track of your .cs files.”??

The only *partial* reason for this behaviour that I can tell is the move to partial classes. Since it's a partial class, it needs the rest of the code generated from the ASP.NET runtime to compile. *I* was quite happy with the inheritance model used before. While partial classes are nice, *I* don't see any personal benefit in using them if it's going to introduce problems like this. At any rate, that still doesn't explain why I can't have a Foo.cs inside any directory (not just the /Code directory) and be able to use it.

Code | Misc. Technology
Tuesday, October 12, 2004 1:38:46 PM UTC  #    Comments [2]  |  Trackback

Thursday, October 14, 2004 10:02:59 AM UTC
Michael, are you sure this doesn't work anymore? I have code from several apps that run without any changes including components loaded in funky ways of different sub-paths. I'm still running beta 1 (not the refresh) so unless something's changed I'm pretty sure that hte old model works just fine. Breakng that would also go against the ASP.NET's team of 100% compatibility...

I agree BTW, about the new code models being a step back in some ways. They are easier to work with if you're not using OOP and don't subclass extensively, but if you do, you actually end up wiht more work. And that is definitely a step back. I haven't been spending as much time with the new version as I've liked but my first impression of the new code models is definitely very mixed. It doesn't bring anything to my code flow that makes life drastically easier. And the databinding still sucks!!!


Thursday, October 14, 2004 11:03:57 AM UTC
Yea, perhaps I didn't make it that clear. ASP.NET runtime still allows you to load stuff from an assembly, and for the most part, apps don't break too much with the new runtime. My real complaint is that the VS project model doesn't expose or make easy the use of this feature. So it's more of a VS problem then the runtime itself. Overall, the new web features are light-years ahead of 7.x. It's simply awesome -- much faster workflow, and well, the designer is finally decent :). This is my only real complaint about Whidbey (as it has been since I got the alpha about a year ago). However, I must say I feel pretty confident that MS will fix this somehow -- it's too big an issue to let slide.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview