<< Back Home
Microsoft.NET : What in the Hell is This Stuff? ...and showing you all the little flaws that come with it...
or "A Common Sense Beginners Guide to ASP.NET that Corrects False Assumptions that Other Developers are Still Making"
PART 1
I am going to give everyone a common sense view of Microsoft's "new" .NET technology and what it all means to those of you just getting started as a web developer. I'm going to talk really about a "subset" of .NET called
ASP.NET, so forget about reading this article if you are trying to learn Windows Programming, though this may help you. And I will try and clarify some short-comings of .NET and the ASP.NET development environment, as well as some greatness in the medium, which few people have seemed to have the enlightenment needed to solve, accept or objectively explain. I think its like any great new technology....we all get a little scared when we find out what we thought we were told was great, turns out to not be so great after all. Or when we, out of laziness, accept something as great when if we had taken our own brains and skills and looked under the hood a little, we would have seen the product we purchased wasn't the "end-game" of our problems after all. Such is the case with the current iterations of ASP.NET in my experience, and Visual Studio 2003, the software that's used to create ASP.NET projects and pages. Its my hope that beginners in web development will get a better view of what's wrong with ASP.NET and Visual Studio. Its also my hope that all the issues I address will be gone in future releases of .NET, and Visual Studio especially, not to mention the way this new technology is organized and taught, so developers like myself don't have to write articles like this.
I realize all you .NET Programmers just might hate me, and what this article begins to suggest about this technology....and my "interpretation" of it and what it does right and wrong. And maybe even those of you just starting to learn web design and development might feel that way. The reason I expect allot of people to read my articles (especially this one!) and get upset, is the fact that some of the information I will be putting out will be first of all, critical of .NET and .NET web developers as a whole, and second, put out what to many may seem like either "obvious" and "dumb" information about getting started with .NET, or in some cases, information that might seem incomplete or even incorrect. Its my point here, as with most of my articles, that the way many people, including myself, LEARN NEW TECHNOLOGY, may NOT be like how other intelligent people learn that same technology. Its not JUST about who's more intelligent, or getting the facts correct...as it is about one's experiences with something and how something did or did not work correctly for them, based on how they do things. In light of that fact, the truth about what is "right" and what is "wrong" and what is "obvious to many" is certainly not going to be obvious to some....and this often includes a whole group of very bright and often creative people that think outside the box. Being an artist, a musician, and web programmer, I like many, fit that creative mindset. Many of us are not the "left brain" savants like most of the programmers who build this stuff (seem to be), and we often have the same intelligence level yet simply do things differently (and better in some cases). This translates to problems learning new software, teachers who fail to explain things to certain groups of kids, and so-called experts making assumptions about stuff that often confuses people, simply because their little minds make assumptions about things that the rest of us don't make. And when that happens, learning fails for many people, like it has for me, in learning ASP.NET, as it seems to be one of the worst places where
programmers all over the globe continue to make false assumptions about how powerful and complete this tool is to them, when to me, from my experience and analysis, ASP.NET and Visual Studio fails on allot of levels for me based on the way I feel most web projects should be developed!
Its simply that ASP.NET is NOT intuitive, and difficult to grasp at first, and the people who talk about it all have something "missing" in how they understand web development as a whole, and all the pieces that make a website compliant, validated, usable, semantically ordered, organized and managed. (Its because they were Windows developers, not web developers, I feel.) ASP.NET fails in many ways, in my opinion! But if it fails in making web development intuitive and carefree and exciting and efficient for a single web developer who uses it, then its failed to help that student achieve success designing websites, period! If he/she has problems either learning it or using it, it's got problems, folks! After several classes, teachers and online reading, its still been a problem for me, especially in understanding WHY certain things are done the way they are....things my teachers obviously never took the time to consider carefully, before jumping into .NET and doing them anyway. Things like poor markup control, code rewriting in Visual Studio, horrible table-based layouts, terrible Internet Information Server (IIs) virtual folder control and setup, and numerous other issues were HUGE roadblocks for me. All students learning this need to see and understand WHY THOSE THINGS ARE DONE POORLY AND HOW TO GET AROUND THEM. And that's going to be my attempt with this article....to get out the TRUTH and help people! After sorting through many of the errors I have found in .NET, I realized things were not working well with .NET for me, not because I was dumb....but because something was flawed in the concepts behind the product for me, and some VERY intelligent people that wrote this stuff were flawed in their assumptions about web development as a whole. Let me state, though, that after allot of "house cleaning" of parts that were not needed in my ASP.NET sites, and review of this product as a whole, that ASP.NET is, finally, a huge success for me, overall, and will be for you, and the journey is worth it! Trust me, as its object-oriented nature can be quite powerful in terms of backend development. But like I said, in the beginning it was not a success for me and if you are a very wise and experienced web person, like I am, it might not be for you at first either when you see how "they do things" in .NET. Just know, its ok to be critical and harsh and realize that what software vendors create is definitely NOT always the right way! Human beings made this software! And none of us are perfect (especially me and my typing skills)...and neither is ASP.NET!
This gets to my other point in a number of my articles, and why some of you may be wary of my ideas. And that is that human beings who build things for other human beings, all have different perspectives on life, on learning, and even on logic, that may go beyond, or even break traditional ways of experiencing those practices. And that affects how one group does things from how others do things. In technology, this means that what's done one way might not work for others, or in some cases not be the right way to do something for many! From this, its an even more important belief of mine, that despite all the problems with software and how it helps or hurts us, software that does things BOTH THE RIGHT WAY AND YET ALLOWS CREATIVE FREEDOM leads to the best software! And it also leads to creative thought....or alternative perspectives that lead people to see or even invent new paradigms of thought and software technology that help us push beyond what the "status quo" in programming may claim is standard practice, yet allows us all to all follow "best practices". Not a clear concept there, but ok....I went ahead and said what I wanted to say!
But again, .NET has been a HUGE productivity plus for me in doing web development, but also a problem for me personally, especially in trying to understand the "ends and outs" of why things were built the way they were....how hard Microsoft and many C programmers make things, and how flat out "ugly" C programmers make things when they design them. When I say ugly, I'm talking about both usability and interface design to the applications they build, as well as "programming" and conceptual development" design that goes into these products, which make it hard for many types of people to understand and pick up. And as a hard core web developer, who has been familiar with ASP Classic, CGI, Style Sheets, HTML, and now XHTML, not to mention nearly two dozen implementations of very complex web information management systems and content and document management systems which I have built completely from scratch, and hand-coded myself, for my web clients, I need to say "I'm no Dummy" when it comes to web development. And that's why its been so frustrating to begin my journey into ASP.NET and see so many
false assumptions made, so many
overly complex structures built in .NET, so many
ugly and incorrect markup coding practices going on, and overall
confusing and poorly explained documentation in place to help those of you who are completely NEW TO THE WORLD OF WEB DEVELOPMENT BUT WHO WANT TO LEARN ASP.NET. And so, this article will attempt to fill in some of the missing information about that technology that you WONT FIND ONLINE OR IN BOOKS, since many programmers and .NET developers have failed to explain those things adequately for you.
And finally, just to be clear before I start, let me say that yes, learning ASP.NET and Microsoft's products are worth it! And yes, they are great, and yes, they will help your career big-time, since so many American businesses will be and are choosing to move into more .NET products. After some years and you master this stuff, yes, it will pay off. But like any new technology, a word of caution I give to you: Despite what everyone is saying, it isn't easy to grasp, and it isn't easy to master. And I'm not talking about the 90% of you .NET developers that build things in .NET everyday....you guys aren't masters. Anyone can pickup a skill and do something with parts of it. I'm talking about the rare 10% of you guys who actually have or want to make an effort, like I am, to learn ALL THE GOOD, BAD AND THE UGLY about .NET, explore the real details about what works and what does not work, want to learn how .NET interfaces with Microsoft's next-generation of products built around this "platform", want to learn some .NET "best practices", and who want to know about all the little goodies in between that make the top 10% good at what they do (versus the mass of .NET hackers out there in the world who get by and accept the product at face value). Those top 10% of you is who I'm addressing and its the new guys and gals that strive for completeness and again, the truth about what works well and what is a stark failure in .NET currently, and that need help getting to learn all these subtle nuances of Visual Studio and ASP.NET, that I'm trying to help. Its learning how to do things the "right way in the first place" that is the subject of this article and learning .NET from the beginning at the same time.
Why Move to .NET: Lets Hack Through to the REAL Truth Behind That...
Ok, for starters, go ahead and read online and in books what .NET is to Microsoft and programmers around the world. There are thousands of sites about .NET and you can easily leave mine and go out and start "piecing" things together on this technology. That's the experience I had. I even asked some of the top programmers I worked with when I decided to make this move, what, in a nutshell, was this stuff, and why do I care? To this day, even they cant really say....other than, "its there"! Here is what it means to me, and why I decided to move from one way of building websites to this new way.....
What .NET Meant to Me...
- More and more businesses are moving to .NET-based products, so for my career, I made that move. It's that simple. Money. Get left behind and you lose it (and so does your career suffer).
- I know "ASP", so since it is being discontinued, moving to .NET is important to you as well, if you are an ASP web developer. (Again, ASP is the old coding "framework" based on scripted and interpreted coding languages like VBScript)
- I have read that ASP.NET is faster, "better", makes developing websites easier and quicker, uses resources better, and again, its the "newest thing", so at some point I knew I had to move into it. The company I work for is a Microsoft-based service provider anyway, so it was doubly important. And being a web developer and starting top design some very powerful information management systems for my web clients, the next most powerful system was important to its success.
That's it! But the truth is....its all really based on money, folks! Isn't anything these days (sadly)? How and why YOU choose to go to .NET will most likely be based on your career and making more money. So, don't go buying into some false promise from some programmer online or Microsoft that there is some magic reason for all this. They want to make money as do you, and that's the name of the game with ANY TECHNOLOGY MOVE, period. Why do businesses move into .NET projects for their companies? Same reason. Making more money and saving money, whatever that translates to. Whether .NET ultimately helps you do that and is any better than any other technology solution....who knows, and that's up to you. But that's why most people are moving into it. Career and making more money, however that "plays out". . Case closed......
What is .NET....wait....first let's kick down the door and compare .NET to some other technologies...
.NET is essentially, just another JAVA-like, object-oriented, compiled development language. That's it! Ok, go ahead and confuse us with all this stuff about intermediate languages and runtime and the common language runtime and the benefits of Visual Studio. That just confuses people. .NET files are just text files that you write in Notepad or a text editor if you like. They sit in a folder on a web server and do circus-tricks. They are just like ASP files. They work like PHP and Java and HTML even. They can do some things the same, and others differently. Ultimately, you can write ASP.NET files anyway you like, following certain coding rules, using a text editor and see them on a website like an HTML file....but it gets deeper from there. Thats all I needed to know before I started this stuff, and nobody told me that in plain English! Its just another "language" or "framework" for coding with languages, so that I can write web pages that are dynamic and talk to both the web server and the users browser in various ways. Well, that's allot like Java, ASP, CGI and any number of other programming languages, no matter how you slice and dice it "conceptually". And I hope that information helps you and comforts you on the initial leg of your .NET journey. Most ASP.NET web files are essentially just plain text files with code you type with a text editor and stick on a server somewhere for the world to see!
Now to explain what .NET is in a different way......NET is essentially is a new way to communicate with the operating system in what you want to do. Say you want to have a web page print out the words "Hello World!". Well, ASP Classic did that one way, JAVA does it another, and CGI or PERL another. PHP even another way. Is .NET any MORE SPECIAL in how it talks to the computer to create that? No, not really. Why? Because its very very CLOSE TO BEING A LANGUAGE THATS BEEN AROUND ALLOT LONGER...and that's JAVA! That's right....if you know JAVA or what it is or how it works or talks to the computer it sits on, its basically like JAVA and so like I mentioned above, just another "object-oriented language" (OOP). Like JAVA it also needs to take the code you type in a text page and then "compile" or turn that into another language that makes your web page run faster. In other words, your code now has to be processed using an "extra step" like most JAVA does, so its now compiled by your computer first. Thats basically what compiling does though it gets more complex. More on this down below, so dont worry. But does .NET have something special about it that separates it FROM JAVA. ABSOLUTELY!!! Its VERY special...but special in what it can do for you, and the way it works....not in how it builds web pages. In other words, it cannot help you build a BETTER website, as you will see....and as it tries to SELL to you. It is (and should be), like JAVA, just ANOTHER TOOL for you as a web developer. Will it be more...maybe someday...but not today! The mistake most .NET Develoeprs are making in understanding .NET, is it doesn't solve ALL WEB DEVELOPMENT PROBLEMS, and even makes a few aspects of web projects much worse! Thats why Im trying to "humble" this tool for you, and in explaining what it is, hopefully you now will feel it isnt better than what you might already be doing with your web development career....simply because it tries to be all things to all people, and in so doing fails. And by trying to pretend to be this large complex technology solution, its really putting itself on a high pedastal where it really doesn't belong. Why? Again, because its just one of MANY good technologies and like any other technolgy, period, you actually will probably find it does some things really well and others very badly (see below).
This all wraps back around to what I am saying about what .NET is. Don't fall into line like some Rock-n-Roll groupie in awe! Its something YOU can do and .NET should be in awe of you the user and web develoepr and what you know about web design and development and respect your knowledge. Unfortunately its developers felt differently, and so in trying to understyand .NET they would like you to know the "new" way of doing things online is best done their way. That is NOT how ANY technology should be taught....it should interface with the rich and diverse knowledgable people out there than have been doing web development for years....but unfortunately, thats not what .NET people do. Its that assumption that your knowledge in doing web development differently, and that you don't know anything until you know the .NET way, and are ready to learn the .NET way, that in my mind makes its such a problem learning it. Its the way you can be forced to throw out years of good experience understanding website development in learning this stuff that is what is so bad about learning this tool. It can be VERY rigid and narrow-minded. Thus we are here together....and I am hopefully passing on the fact you NEED TO TAME THIS BEAST before it tames you...and thats by first knowing you can type text in a text page and it can be a .NET web page, with no special technology knowledge. And so in explaining again, just think JAVA, then .NET and though they are different and .NET is far superior to JAVA in my mind, its still not the complete and mature technology you might think it is, and which so many .NET developers will try and convince you it is. Just feel comfortable that .NET and its languages are just another family that includes all the other ones out there. Its a member of a large family of technologies you have the power to choose over .NET, simply because its comparable and so much like them in so many ways.
Just know that yes, you can get out a text editor, and type in HTML markup into .NET, .NET pages, and .NET web servers and so create .NET code like any other language you are used to. YOU DONT HAVE TO HAVE ANY MICROSOFT SOFTWARE to do that. To run it you need the FREE .NET "framework" and possibly the SDK or software developers kit. But thats also all free and dont worry about that. Ill help you get all that. Just, don't think you need expensive software like Visual Studio at first, to create this stuff, though as you grow comfortable with .NET you will want to buy all that junk and actually use it and it will help speed things up. Just dont get intimidated and scared by all the new .NET talk and products they shove in your face. Just get out old trusty Notepad.exe, download the framework (below) and you can start learning FOR FREE! Don't be scared like I was or feel obligated by IGNORANT TEACHERS from all over the globe bragging and blabbing about Visual Studio and their incredible knowledge and how to do things using Visual Studio and how you need it for .NET. THAT IS ALL WRONG....and I will show you why initially why those products are good later, but at first, teach very bad habits and create some very bad code (markup). After you have that piece of information, when you DO buy them and need them, as I expect you will, you will at least know what they do right and WHAT THEY DO WRONG, as far as building websites goes! I thought something "magical" had to take place with me and Visual Studio and .NET, or I had to buy other expensive software if I wanted to convert my HTML static parts or pages of my site to .NET. Not so, so don't buy into that. Keep things simple and know .NET isnt anything special really, in terms of what it means to you as a simple web developer building simple HTML pages, for example. It cannot give you anything more than confusion if you dive into the products without first trusting me on this simple fact....of what .NET is "like" and how you can start out with simple text files and clean markup. But it does get deeper from here forward, so follow me closely people....
What is ASP.NET...to me, that is
Lets redefine things a bit more concerning WHAT IN THE HELL .NET is. First of all, .NET is a "loose term" for a new object-oriented "architecture, or core set of "files" that run from a set of folders on your computer and supports all the other applications and websites and services that run on that machine and use the .NET objects and architecture. In other words, .NET is a global term referring to Microsoft's "new way of running software", basically, and the set of DLL's, files, and folders you download to your box that run all that "new stuff". All the new XP operating systems for Windows have the same .NET "files installed and the new systems will be pretty much saturated with .net architectures to run all this stuff. Again, as with anything in my primitive little article, you can go online and get deeper into details, but my point here is to fill in some basic "holes of understanding" that I found with all the documentation.
I wish someone had explained things to me this way!. Now to continue....what .NET essentially is, though, in terms of physical files, is a bunch of DLL's and other "stuff" that your computer downloads from a site like:
http://windowsupdate.microsoft.com
Sure it's much more than a download, but that's basically what .NET is. Why, because .NET is a new technology that some of us didn't have, if we use Windows operating systems that are older than the latest XP version. So, if you are like me, and sometimes use Windows 2000 Home edition or Professional, if you go to the site above, you will have the chance to check for updates to your operating system and download this ".NET Framework" set of files to your PC. It's that simple. Now, what .NET is also, is the foundation for allot of Microsoft's new products, like Office, etc. I wont get into that but say that .NET is really allot of things, so when you here that term, think first files that you download to your computer, think object-oriented "stuff" that makes programming faster and easier, and that its an "architecture" or "framework" for all of Microsoft's new software. Just keep that in your mind and don't worry if it's still vague. Lets continue...
Now, there are what I call "subsets" to the term ".NET" that represent technologies inside or under the basic conceptual term .NET. These include both product designations as well as conceptual designations. So, don't get confused like I was. For example, you will see people talk about web development as being a part of "ASP.NET". That implies that "ASP" is a subset of .NET, or some special language or product. Actually its not! You will also hear "VB.NET" and then "VisualBasic.NET" and then "Visual Studio.NET". Talk about confusing! What a mess! What does all this mean? Well, think of it this way....".NET" contains all .NET-based technologies...including conceptual terms and ideas, programs and software, languages, and "technologies" based on .NET. So, when you see all this junk, just take it with a grain of salt, and don't get confused or really impressed. It's not very helpful except as a very generalized conceptual term. Back to my discussion about .NET.....if you are a web developer, you will need to know what ".NET" means to you. Good question! Well, it includes many possible .NET terms that you will see thrown at you. They might include, "c#.NET, ASP.NET, VB.NET, VisualStudio.NET, etc." Don't be confused. Here is how I understand it. .NET is a general term for a bunch of files that form a new framework or architecture that's object-oriented and sits on your PC, or some machine somewhere. Allot of "stuff" can run "on .NET" using .NET-based technologies and other stuff. In other words, if you are doing web development and want to program using .NET-based technologies, then you would start with "ASP.NET". Well, ASP.NET "includes" other "stuff" as well, like software to build ASP.NET programs (which is termed VisualStudio.NET or the new software for building all .NET applications), VB.NET (which is a loose term for both a language found in ASP.NET-Visual Basic and a loose term for ASP.NET itself), c#.NET (same as VB.NET...another language under ASP.NET and a term for ASP.NET) and other stuff. Just remember, that ASP.NET is going to be the term most likely attached to "web development under .NET" in general. That's what confused me. But don't let it!
Also, we need to talk about the ".NET Framework". This is another confusing term that developers throw out to people, but it actually has several meanings that you need to be aware of. We talked about .NET as a framework that you download and sits on your computer. That's actually how ASP.NET works, in that it uses the "framework" to "run" your code you type into text files. In other words, as you build ASP.NET web pages and projects, the Framework is actually running in the background and you might think of it as one of the core set of files that runs all .NET software and "stuff" on your computer. Without it, when you create ASP.NET projects and files, you will find they will not run. This shows how important it is to understand .NET as on one level a bunch of files (DLL's or dynamic link libraries in many cases) that sit in folders (usually found in your c: drive of your computer under c:\\WINNT\Microsoft.NEt) on your computer or server box. That's it!
Now, ASP.NET, like anything based on .NET needs the "framework" to run, so you generally can download the "framework files" and then start building web pages as ASP.NET files on a web server with the "framework" and it runs them. Lets look at what ASP.NET really is, though, from a "dummies" point of view.
When you create an ASP.NET file for a web project, its just like an ASP or HTML file with an extension. This time, though, you will see differences that I will explain. You can create a TEXT FILE and type some text and HTML markup into it (call it say "hello.html") and drop it on a server with the .NET "framework" installed and when you view that page its the same html web page. If you change its name from say "hello.html" or "hello.txt" to "hello.aspx" (the correct way to name an extension for ASP.NET files) then it will still look the same and nothing different happens but its suddenly using the "framework" to process it. If you change it to "hello.asp" it looks the same but this time its using the asp DLL processor on the server to process it. The important point here is that the extension determines how and who is processing your web pages. That may seem obvious to you hard-core developers, but it wasn't to me with .NET. And it underscores what the .NET "framework" does, and that's simply that after you install the framework and .NET files on your computer, that they run all web files with the .ASPX extension and that means your websites is OFFICIALLY A .NET OR RATHER ASP.NET WEB SITE! Thats right! That's all there is to it, for you as a beginner, to be tapped into using all the incredible and awesome object-oriented and "fancy-wancy" little Microsoft big-time and expensive 'stuff" they are touting and prancing about with in articles and news wires all over the world! In other words, .NET and building websites in .NET is essentially about:
- Making sure you install the .NET "framework" on your web server or machine!
- Making sure you name your files with the .ASPX extension!
That's it! Now, it gets more complex and more involved from there, but that's essentially it! This leads me to backtrack now to another point about .NET and ASP.NET. This technology requires IIS (Internet Information Server/Services), or rather a "Microsoft web server" running on your box, or that the web server you install the ASPX files be running IIS with the framework installed. You may not be aware but 2/3 of all web servers worldwide are Unix/Linux-based which uses a completely different operating system than Windows and IIs. So, make sure your host provider has IIs installed or request they move your site to a Windows or IIS-based server. All good hosting providers have both flavors! So to backtrack...three things you need to start learning and running .NET or rather ASP.NET, and for free!
- Making sure IIs or Internet Information Services or Microsoft's Web Server is installed first (free from Microsoft if you have purchased Windows 2000 or XP Professional Operating System CD's for your PC)
- Making sure you install the .NET "framework" on your web server or machine! (Free from Microsoft using the downloads link listed earlier in this article!)
- Making sure you name your files with the .ASPX extension!
As a side note, if you own Windows 2000 Professional edition or XP Professional Edition, you can run IIs web server for free on your machine! Its on the disk and usually not installed by default but go to your control panel, and got to Add New Software and add a Microsoft software, and insert your disk and you will see IIs. Again, make sure you INSTALL IIS first, THEN INSTALL THE .NET FRAMEWORK LAST, as per the link listed about. That's it!
What is ASP.NET and this 'Compiling Nightmare!'
Now for the good, bad, and the ugly, folks! ASP.NET is the "concept" we now know behind everything "web-based" under Microsoft's .NET architecture. With IIs web server running and the .NET "framework" installed, you are ready to start building the .aspx web pages that allow you to dive in! Now for some other things no body online will tell you! ASP.NET is THE SAME BUT ALSO DIFFERENT THAN ASP! That's right, and you may have read that, but still don't know what that difference is or why it matters! No body explained that to me, and it took 100 hours of reading and researching to figure out what all that meant and why! So, here is goes.....ASP is now called ASP Classic which is the same as ASP 3.0. ASP.NET is ASP +, or ASP Plus and the new .NET-based technology right? Well, ASP or "old ASP" is what is called an "interpreted language" meaning when the IIS web server and the ASP dll file or "engine" that used to run your old ASP files is run (when the "hello.asp" file in our example is accessed by a web browser and processed on the web server), it reads the page of code and processes it right away, then write out the file code and html and send it to the browser. Easy enough, right? Well, in ASP.NET (and the "hello.aspx" page), its read by the .NET Framework and its "compiled", or rather "pre-processed" into a dll or dynamic link library or at least into a bunch of "objects" and stored in the dll or memory which the .NET framework uses to run it securely on the server. Its allot more complex and involves other confusing stuff like an "intermediate language" or "half-machine level code base" and then when the page is accessed, that .ASPX page is processed a whole lot faster by the computer when it builds and sends the page to the users browsers. Actually it's built and like the asp page, sent to IIS, which ships it out. I don't want you to get confused like I was about the CLR (common language runtime) and MSIL (Microsoft Intermediate Language) and all that crap. Just know that ASP interprets or reads the code and processes, while ASP.NET runs a "compiled" versions of your page code stored in a file or memory somewhere on the server which is controlled by the .NET framework mentioned earlier.
Its obvious that some incredibly "crippled" Microsoft programmer stuck in the left-brain world of Windows Compiled Languages wrote this junk that way without even thinking about Web Developers, as the whole thing is incredibly "convoluted" and "antiquated", despite all the hype surrounding the benefits. What I am NOT saying is it's a "bad thing" this way of doing things in .NET framework and in ASP.NET. It's actually better. What I'm pissed off about is how confusing and alien this is to web developers in general. As a web designer turned programmer its especially irritating that the guys who wrote this would assume that everyone's brains works this way. It can take you five times the amount of time and brainpower now to write out the words "hello world" dynamically on a web page, and deal with all kinds of "compiling errors" that you never experienced with simple interpreted ASP or PHP or CGI code. So, I have to say, something was terribly lost in .NET and ASP.NET especially. That's a fact! That's why I'm writing this article. So, to again clarify, ASP is interpreted code and ASP.NET is compiled, meaning, one has to send ones code through a special program first where it is organized and written into another "language" or form of that language first before it can be viewed and tested. Not good, but that's the facts, folks!
Now in defense of this difference, there are some benefits. One is faster code, the other is code that cant be "ripped" by hackers, as its rewritten or compiled into a new more secure machine-language-like file, which is usually a .dll file in the "bin" folder that's included in every asp.net website you build. That's usually where this faster, more secure "beast" is stored. So, there is a physical place for this stuff when you compile it. Again, my point-of-confusion with .NET and ASP.NET was this "compiling" process. It seems like another roadblock between a developer and testing his/her code. But "se la vi", and that's what you need to get used to with ASP.NET. You type in your code, you compile it, you pray no ERRORS IN COMPILING occur, and then you can view it in your browser. With everything in .NET there are lots more pieces and variables involved, like the fact you DONT HAVE TO have dynamic code in your actual .ASPX pages compiled at all, if they are static and don't have dynamic backend content. That leads me to the next concept....
ASP.NET CAN INCLUDE YOUR OWN CAREFULLY CONSTRUCTED HTML MARKUP....NOT VISUAL STUDIO's MESS
First of all, just because its an ASPX page means nothing as to its true identity. Actually, an ASPX page can be anything! ASP.NET = VB.NET = c#.NET = j#.NET = HTML = XHTML. Thats right, ASP.NET can be written in a variety of languages as long as you add the right "directive" or indicator at the top of your ASPX page. An example below:
<%@ Page language="c#" %>
At the top of any .ASPX you write you can add this "directive" that tells the ASP.NET framework which language to use in "compiling" your page. That's helpful and important and also powerful as it means if you are a c++ guy or VBScript ASP/Visual Basic programmer, you can use the same syntax you are comfortable with. BUT, this applies to how you control pages that use dynamic data, like calls to databases and server-side junk. For static pages, YOU DONT HAVE TO HAVE A DIRECTIVE OR MAKE YOU PAGE INTO ANYTHING. The Web server and .NET will send out your ASPX page with your HTML or XHTML as is, as long as you don't add any of this special junk into it that tells it to use languages and make calls to server objects. So, don't be afraid of using ASPX pages for plain HTML code. That's all I will say about that and you can read more about that online. But the important thing here is the fact that the .ASPX extension means very little in terms of WHAT YOUR WEB PAGE in ASP.NET REALLY IS OR DOES?!? In other words, in ASP the .ASP extension means clearly you have a page that most likely had some dynamic content you wanted to write out in HTML. Not so in ASP.NET. When you build a text page then give it the ASPX extension, it can be any number of things. By adding the directive at the top, you can control, not only what language the page is going to be written in (or recognized by the framework as being processed in) but you can determine if its dynamic or not, whether it will show debugging code, whether it will return plain html/xhtml or special javascript, etc! The reason for this is in most cases, the ASPX page doesn't control the server-side code, as that's now separated out and will in most cases be found in the matching "code behind" page. This means ASPX pages in general are you place to place all your static markup and code. I wish someone had told me this simple fact also! Just keep in mind, that's generally true, even though dynamic web form server control markup tags will be sprinkled in and you will get comfortable with the relationship between these server control dynamic ASP.NET tags found in the ASPX page, your static markup, and the code behind pages where most scripting on the server-side is stored. If you can get used to this concept, and are like me, an XHTML guy moving into
Web Standards in all your web projects, you will see one great concept of .NET. Like XHTML separates style and presentation in style sheets in one file from the XHTML markup in your XHTML page, so too, the ASPX markup is separated from the dynamic code behind and server scripts stored in the "code behind" script page! That's quite a powerful concept, the separation of markup from style presentation from backend dynamic code. And using XHTML, CSS, and ASP pages in tandem will someday, I believe, really make ASP.NET a superior technology, if they get Visual Studio 2005 correct and fix these bugs! Separation of these pieces, and especially the server code form the static markup, is key to enterprise level control over websites and fast development (more on that in another article!).
But back to say it again (as its so important and nobody tells you this!)...that's the
next huge mystery surrounding ASP.NET and the ASPX page nobody explains to you....that an ASPX can be anything! If you don't add any extra code, you can actually paste in PLAIN HTML or XHTML CODE FROM YOUR HTML PAGES AND IT WILL WORK AS A PLAIN HTML WEB PAGE! I thought this was the most understated feature of .NET that NO WEBSITE OR EVEN MICROSOFT explains! Just because you have fancy software that builds all this special compiled dynamic code doesn't mean you have to use it! You can simply turn a plain static HTML page into ASPX by renaming the extension. What's the advantage to doing this....well, nothing really, except the concept.....and that is that ASP.NET is not some special coding or development platform that need take over all your markup or code and recompile it into some hidden inaccessible beast you cannot control. You can MAKE ASP.NET WORK FOR YOU and turn your plain HTML pages into ASP.NET pages. Again, this doesn't change a damn thing, other than the fact that your page is run by a different engine on the web server...the ASP.NET framework "engine" as I call it. But its still HTML and that's important for beginners to understand....just because its ASP.NET doesn't mean you have to stop coding in good clean HTML or XHTML, or even lose your style sheets. You can take a plain static HTML site, with no dynamic content and turn it into ASPX pages with the extension, drop that on a IIs web server with the framework installed and it may use the .NET objects now to run it, and even compile and store it in memory and run faster, but its still spitting out your AWESOME CLEAN HTML markup you have so carefully built over the years! This concept though understated and silly to some, is really vital and critical to me to showing that web designers don't have to be "enslaved" by Microsoft's narrow concepts regarding web development and can do things that lie outside the realm of Microsoft products...and I'm talking about using Web Standards and markup practices as handed down by the www.w3c.org. In other words, the world of HTML and XHTML and CSS is one involving markup languages and designing for various browsers and agents excluding Microsoft and ASP.NET. And that's important to understand, that just because your web shop moves to .NET, doesn't mean that you have to throw out carefully designed markup and do things the Microsoft way. As we will see shortly, you will see how pitifully bad their code from Visual Studio is in terms of HTML design and how important it is for web designers to feel free in carving up and adding and editing by hand their own markup inside of those parts of ASP.NET .ASPX pages that are NOT dynamically controlled. You can move and rename your html and with careful considerations keep you markup but add the benefits of ASP.NET in terms of SERVER-SIDE CODE only, if you choose. When I talk about Visual Studio, you will see how that software can at times hijack your markup and stick really poor HTML and XHTML into your code and ruin accessibility, usability, and validated code if you are not careful. Just keep in mind you can use your own html and just because its ASP files doesn't mean its not just a plain text file with some html code you typed, in it, designed you way you want to do it and control it. That's also important!
Part2
Now Let's Looks at How Bad ASP.NET and Visual Studio ASPX Markup can Be
What I have listed below is a small block of code that was taken from a web page that was built using Visual Studio and ASP.NET that I built. It is not complete, but just a "snippet" of code taken after doing a "View Source" in Internet Explorer on that dynamic web page. This page uses all the recommended "widgets" that the "Web Forms" gurus recommend, including server includes, state, validation and some other stuff. Lets look at the code below. Be sure to note the long string of text in the hidden input, the JavaScript and the table markup. I am then going to pick this apart and show why you need to use ASP.NET carefully and show you how bad its markup can be, so you don't fall into place like a good Microsoft foot soldier and end up making a horrible mess of your websites:
<form id="Form1" runat=server />
<input type="hidden" name="__VIEWSTATE" value="dDwtMTg1NDkwMjc0Nzt0PDtsPGk8MT47PjtsPHQ8O2w8aTwxPjs+O2w8dDxAMDxwPHA8bDxWaXNpYmxlRGF0ZTtTRDs+O2w8U3lzdGVtLkRhdGVUaW1lLCBtc2NvcmxpYiwgVmVyc2lvbj0xLjAuNTAwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODk8MjAwNC0xMi0wMT47bDw1MDwyMDA0LTEyLTIxPjs+Oz4+Oz47Ozs7Ozs7Ozs7Pjs7Pjs+Pjs+Pjs+M2cINzr7rrdCLUe2K/7adlbIUL4=" />
<script language="javascript" type="text/javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
theform = document._ctl0;
}
else {
theform = document.forms["_ctl0"];
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
<h3><font face="verdana">Applying Styles to Web Controls</font></h3>
<p><font face="verdana"><h4>Style Sub-Properties</h4></font><p>
<table cellspacing="2" cellpadding="2" rules="all" bordercolor="Black" border="3" style="color:Brown;background-color:Beige;border-color:Black;border-width:3px;border-style:Solid;font-family:Tahoma,Arial;font-size:12pt;height:450px;width:450px;">
<tr><td colspan="7" style="background-color:OliveDrab;border-color:DarkOliveGreen;border-width:3px;border-style:solid;height:50px;"><table cellspacing="0" border="0" style="color:Brown;font-family:Tahoma,Arial;font-size:12pt;width:100%;border-collapse:collapse;">
Ok, I ask you, what's wrong with this code? Why is it SO BAD!
And how long of you "seasoned .NET developers" have been oblivious to how POOR the front-end code is in all your web projects using ASP.NET and Visual Studio? Still not sure what is wrong with the code above? Ok, I'll tell you what's wrong:
- For starters, ASP.NEt is using a special "hidden" form control to control "state". In other words, the page requires a large "form control" wrapped around all the markup with this hidden control with this HUGE name-value string called "VIEWSATE" to try and track each user in your website using the web controls in your pages. Not good....why? Its bad because wrapping markup in a form for this purpose is semantically wrong, and defies the purpose of the form tag itself, which is generally only used as an INPUT tag for input, not maintaining state. Its a "noble" idea and "novel" as well, but by being "semantically" wrong, it means the markup is being used for something is WAS NOT MEANT TO BE USED AS! As a markup designer, are you ok with wrapping your page code in form tags? Bad decision Microsoft! Also, look at the length of the posted string for that state....wow...that's another couple hundred bits to your page size and what's more, its quite nasty!
- Ok, what is this JavaScript doing in my code? I did not put it there! Sure, maybe it's helpful and cool and "sent" only to IE users by my server, sparing all the other agents. But I DONT WANT JAVASCRIPT in my pages! Sure, I can set a property in ASP.NET and turn that off, but wow, why is ASP.NET dependent on JavaScript as a technology? That seems like very old-school stuff (i.e. circa 1997). What about all the new security software and corporate proxies that strip out or block scripting? What about mobile devices, many of which don't support scripted pages or whose carriers don't allow JavaScripting? Why should ASP.NET put something in my page I never asked for? This is a complete disrespect and false assumption on the program's part that I EVER WANT JAVASCRIPT IN MY WEB PROJECTS PERIOD! Another reason ASP.NET and Visual Studio is so bad on the front-end!
- Ok, now for the WORST part....these FONT tags and this table you see wasn't in my original web page. It's generated DYNAMICALLY by .NET. Not only do I have NO or LITTLE control over the tabbing and indentions and case of the tags (which breaks XHTML rules) but the use of FONT tags and INLINE STYLES are both a HUGE NO-NO's in any markup design online. WHO THOUGHT UP THIS MARKUP?! Wow, how bad can you get? Are there ANY developers online that accept this as output into their websites? The FONT ELEMENT as used means I now have to customize EVERY PAGE, or at least, EVERY CONTROL USING VISUAL STUDIO to try and set properties to stop this output. Turns out, you cant stops ALL OF IT! You may be saying...really?!? That's what I said when I realized I could control some properties of these table-based formats and others I could not. What a MESS, Microsoft! To make things even worse, look at the font sizes....they use pt or POINTS! That means MAC web browsers will interpret those based on 72dpi systems and they will look smaller to that group. Point font sizes in general are designed for PRINT-BASED STYLE SHEETS...not desktop browser font sizes. They picked the absolute WORST default font sizing possible for this technology! Means that those sizes are NOT resizable as they are in what is termed ABSOLUTE font sizing, and in a funny way, because Microsoft's own browser (Internet Explorer versions 3-6) does not support resizing on absolute font sizes, any user that attempts to resize these fonts in the web page will not be able to do so, in most cases. The whole INLINE style is just plain bad as well, as now there is no way to "CASCADE OVER" those elements and their look-and-feel using traditional linked style sheet or even embedded style sheets!
I mean, how BAD can it get for ASP.NET! This is not to say there is not a place for say, inline styles, but for this piece of software to be putting out THAT as its main form of presentation and markup control as well as table-based layouts, mixed cases tags and other crap, shows how incredibly "challenged" some of the developers were in designing the markup in this product. Its almost as if, they didn't know html....wow!!!! What a revelation! That's why, I'm saying to you, be CAUTIOUS with ASP.NET and don't take this product for granted as so many gung-ho developers in the world today are BLINDLY doing, as there are some very bad and some very good parts to this new technology. Take it all with a grain of salt and WORK AROUND as many of these problem as you can as you learn this stuff. I found I had to abandon many of the web form controls and am waiting to see if Visual Studio 2005 and the next Internet Explorer fixes these problems. Till then, I'm "gutting" my code as much as I can and hand coding in good clean markup and server-side code and "cherry-picking" this technology carefully (as should you!). Just because it "looks good in IE" doesn't mean you are doing things the RIGHT WAY! You be the judge..... Again, ASP.NET and Visual Studio can be used to create powerful backend software but the front-end, that's a different story!
ASP.NET ,like MOST WEB SOFTWARE DEVELOPMENT PRODUCTS IS GREAT AT SERVER-SIDE AND SUCKS AT CLIENT-SIDE
As we dive into the meaning of .NET and actually what it means to you as a developer, one of the things you need to start doing is separating the two halves of .NET. Nobody does this I know, but me. But I cannot tell you how critical it is to getting control over the beast that is .NET. It seems that when they designed .NET they built it around their own proprietary software so that developers would HAVE to code using this expensive stuff. Well, the big .NET software that's out there is Visual Studio, and so the term VisualStudio.NET is thrown around when people talk about ASP.NET and .NET development. Don't get confused! You DONT NEED Visual Studio to do any ASP.NET programming but its recommended as access to all the objects in the ASP framework is found in that software. So, yes, I recommend buying it and using it to develop sites. This leads to my point earlier.....Visual Studio helps you build incredible back-end database accessing code, but HORRIBLE FRONT-END CODE! Much like the failures of code building in Marcomedia's Dreamweaver for me, I've found all these GUI's miss the boat big-time in delivering credible front-end markup. This is especially true in Visual Studio 2003. Now, 2005 is supposed to correct this. As a strict XHTML and CSS coder, I've been VERY VERY disappointed with the way that Visual Studio writes and rewrites your carefully constructed markup. The tables and front end code is frankly beyond horrible and the XHTML is completely missing in the 2003 product. This means that your pages may claim to be "viewable" in all the browsers, but it's not true. Bad ugly bloated markup is just bad ugly bloated markup, period! I have not yet explained the next level of ASP.NET and that's the "code behind" structure, but wanted to just get this out there, that first, ASP.NET can be built as HTML first. Second, It can be build in say Notepad or a text editor without Visual Studio Software (though its difficult), and you HAVE to try and use Visual Studio, if you do, so that as you build in ASP.NET you abandon and do not use the "Web Forms" built by Microsoft, as they create horrible front end HTML you cannot control fully or rewrite. You are locked in and it's the one stark failure of the new crop of Web Software Design tools out there! They take all control away from the programmer to design good clean html and XHTML, and unless this is corrected in 2005, I have to offer up caution if you are into compliant good clean fast HTML markup and code like I am. DONT USE VISUAL STUDIO for front-end development! For database and code behind work its awesome and seond to none, but not front end!
What this means for you the beginner is the idea of getting used to the idea of the "code behind" page and how BEST to use it in this war between good markup and the powerful backend work ASP.NEt provides. This code behind and separation of server-side code from your markup ASPX pages is the new concept in ASP.NET and its basically just a special text-based code file with the same name as your ASPX page that sites beside your aspx front end page in your web folder and handles all processing for that page. For example, the "hello.aspx" would have a "hello.cs" or c# code behind page and extension. In this page is where you would control all aspects of page processing and any dynamic data spit out by the server. The data in the codebehind sister page is represented in the aspx pages by "sever controls" or special front end code like <asp:label />. This special "xml" namespace of code markup snippet means that the sever will attach something special the codebehind page makes to your markup. Again, there are plenty of resources online to learn about the codebehind and it's the central part of what makes the ASP.NET architecture so wonderful. But the "sever controls" and especially the Microsoft "web forms" ones are what makes it so bad....in terms of markup and page layout they output into your ASPX pages!
What essentially happens is every web form like the "label" one above spits out a piece of prebuilt markup, like in this case, a "span" element, with the data created inside it. Sounds good on paper, and most developers are loving this as they can finally be LAZY AS HELL AND AVOID THE CRITICAL AND UNDERVALUED IMPORTANCE OR A GOOD WEB DESIGNERS MARKUP SKILLS and simply except what Microsoft spits out here. What it spits out in the 2003 version of the software is
non-compliant html table junk, and though they claim it also does browser sniffing and spits out other versions, the whole framework here is bad! Why? Because ASP.NET web form controls deliver HORRIBLE HTML that you cannot influence or change. There are some exceptions...like the "DataRepeater" which is a the only breath of fresh air in allowing designers the power to spit out dynamic data and custom markup wrapped in code of their choice. But the Datagrid and DataList are really bad. I wont go into more detail but if you buy Visual Studio, run a DataGrid table into your ASPX pages and then go here and see how non-compliant that code is (no matter how it looks in your browser):
http:validator.w3.org
ASP.NET, and What they don't tell you about the SDK
One of the problems I found is the confusion over developing on your computer in ASP.NET. One of the main problems is nobody online mentions all the different ways to get a simple ASPX page working without all the debugging and compiling errors one usually gets with this technology. To cut to the chase, I'm going to list the things you really need to make sure you have to use ASP.NET and start building websites:
- You need a Windows machine with Windows 2000 or XP. You also need to get the Professional version that comes with the IIs web server. If you are lucky and have access to a Windows 2003 Server, then that's even better. Again, the "web server" is just a disk with some software on it....its not a special box you have to buy. You can also just buy some cheap hostiong and ask them to set you up with IIs and the .NET Framework, which all of them have now.
- You HAVE to have the IIS installed, then install the .NET Framework from Microsoft's website. Again, its FREE!
- You now can start adding ASPX files to a web folder you are working on and the framework will start using them. But guess what, THEY WONT COMPILE! To really do that and start testing and compiling web pages in .NET, you either need:
- Visual Studio Software
- .NET FREE SDK or software development kit, which comes with compilers. It's a pain in the neck to install and compile manually but nobody told me I had to have this when I started to compile. Even with it, it may require Visual Studio. Just keep in mind, ASP.NET pages are just text files, in most cases, you can open and edit with a text editor. But some parts, especially if you start using codebehinds, will require a "compiler" to build the DLL's in the /bin folders that run your dynamic parts of pages
Its the SDK that is something very few developers talk about
ASP.NET, the Internet Information Services Web Server Setup Nightmare!
As cool as ASP.NET can and will be the way it interfaces with the IIs web server is by far the most illogical and ignorant thing I have ever seen in technology. If you have ever developed we sites, you know there are many places you may want or need to place web files and site pages. Most of the time all these fall under the "web root" or actual "virtual website root" of your website and domain. There are also times, where some of you web mastering experts might create what are called "virtual folders" or folders that exist outside the physical web root, which on most Windows machines with web servers is c:\inetpub\wwwroot. So, you could have a folder in say c:\myfolder but create a virtual directory that points to it from c:\inetpub\wwroot. Or, if your website was called "hello.com" with a subfolder called "world" that that "world" folder could be actually found at "c:\myfolder" using the mapping created by the IIS virtual folder. To make a long story short, it seems that the ASp.NET engineers came up with a very confusing concept, when creating "new ASP.NET web projects" in Visual Studio, and of sticking ALL ASP.NET files and project folders, etc. in a "subdirectory off of the "Web root". In other words, if you use Visual Studio, get ready for a conundrum or logic puzzle, as you will be forced to create and run your project in a physical folder one level deep off the "c:\inetpub\wwwroot" folder on your box, which in addition, HAS TO REMAIN IN YOUR WEB SITES ROOT FOLDER. Yuck!!!! Who thought up that concept???? What makes this really bad, is the fact that MOST WEB SITES AROUND THE WORLD DONT USE THIS STRUCTURE AT ALL! In other words, most websites and website development tools create new web projects in a physical folder YOU GET TO CREATE AND NAME, and WHICH IS IN THE ROOT OF YOUR NEW WEB PROJECT YOU CREATE AND CONTROL on the server! That's right, sounds simple....the website root is where you store your web project! Sound logical. Well, they f*cked this one up bad! Get ready.....when you create a new site, all those files are stored OFF the root of your default website, which by default is mapped to the "c:\inetpub\wwwroot" directory. In addition, that folder is turned into a "web application" (also not good always!) AND guess what, when you migrate your site to the actual PRODUCTION OR LIVE website root folder, wherever you host your site, allot of stuff BREAKS, especially any paths you used that referenced absolute paths, simply because the web root in your development server created by Visual Studio is one level deeper than the root used in your live site. Unless you use the exact same structure used in Visual Studio and ASP.NET, namely, of a "web application" folder one level deep off your web root and stick with that, get ready for a nightmare trying to re-map paths and links to accommodate the two environments!
I like to use absolute paths and they are, I am convinced SUPERIOR TO RELATIVE PATHS in every way but one....and that's if you are moving groups of folders and files or anticipate doing so higher or lower in your web project. That's it! Absolute paths solve all kinds of management and "pathing" problems associated with everything from consistent image folder path mappings, where you want to be able to use the SAME PATH FOR ALL YOUR IMAGES IN ALL FOLDERS through the site. This has the powerful advantage that if you manage all images in a central folder, you can use software like Visual Studio or Dreamweaver to quickly and consistently search and replace all paths! Absolute paths also work in all website folders and folders no matter WHERE OR THEY ARE MOVED in the site. Finally absolute paths allow JavaScript and Style Sheet includes where references to those scripts and rules are served via a consistent path that's always relative to the website root!
Why .NET engineers elected to favor relative pathing and the sub-directory project system on the web server is beyond me, as the use of such pathing makes managing paths a folder by folder and file by file affair and as well, using relative paths and a subdirectory for files that will all have to be moved one level higher on the actual live server, seems to me a real mess!!!
What I'm hoping from this article (which I will be adding to over the coming months) is a word of caution and understanding in using the new .NET environment and world you may find yourself in. I'm not advocating this is a technology with such huge failures its unusable or lacking maturity enough to use today. What I hope you get from this article is the revelation that what you thought were good qualities and firm assumptions towards .NET and ASP.NET are now both clearer, more resolved, and with some air of caution which might guide you through this technology with a clearer sense of what to use and what to selectively toss out the window, as I have. Its made my code and my websites work allot better and kept me from being sucked in like so many developers using this technology and praising it as the end-all and be-all for all their heartaches....when it clearly is not! Somewhere along the way they missed the boat and did not bother to work with seasoned web developers in developing ASP.NET. That's obvious!
But, good luck in your use of ASP.NET and again, use these thoughts in helping you approach this great new technology with more realistic expectations, and visit my site often and lets all remember, no matter who the manufacturer is, or how great the promises are or how cool the technology, don't lose site of YOUR PROGRAMMING POWERS, and that means the power to DO THINGS BETTER THAN THE SOFWTARE VENDORS. You have the power my friend, so don't be blind-sided by the shortcomings or the greatness of .NET but take it for what it is; a powerful but still limiting tool built by humans who make mistakes (like you) and take what is valuable for yourself and depend on your OWN TALENTS to take your web career to the next level.
- Mitchell Stokely, USA