« BRB | ^ Main | Give Atlas a name... »


ASP.NET SUCKS!!!!

LIES…ALL LIES! Whoever started this lie is…err…a liar. :-)

Ok…KM is wrapping up an ASP.NET site and I did a lot of medium-heavy lifting on this one so I could learn more about it. I was guided initially but then came into full swing and ended up working on a lot of the site, which was a great experience. By stepping into the front line and actually getting dirty, I was able to realize several things about ASP.NET (2 specifically) development. I’ll list a few here and will try not to be long winded. :-)

#1 feature - Debug Mode
This is untouched by CF and PHP, the main languages I deal with on a daily. My normal way of testing was to refresh the browser after saving a change, which is fine, but at times I got some funky behavior and I couldn’t figure out why. Well, throw a breakpoint in there and hit Debug. Once the debugger is started and your page starts loading, the code will stop at your first breakpoint. Hover your mouse over a variable that has already been passed (a line number prior to your breakpoint). I dare you! What happens? You get the value of the variable. Ok…that didn’t have as much dramatic flare. YOU GET THE VALUE OF THE VARIABLE!!! How sweet is that? Now, I can see, without having to do all sorts of dumps, etc, exactly why I’m getting an error or the data isn’t right. This is by far the number one feature I encountered.

#2 feature - URL Rewriting
This was a phat enhancement. We used the UrlRewritingNet.UrlRewrite dll and it was great. We were able to turn /blah/name.aspx into blah.aspx?title=name. Now, URL rewriting isn’t anything new. This was just, BY FAR, the easiest implementation yet. In the Web.Config we added a new configSection for the urlrewritingnet node and in the urlrewritingnet node we add a node with rules. Specify the virtualUrl and destinationUrl (along with other params) and you’re done. It is easy as pie. Don’t believe me? Ok…lemme paste some code.

<urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" compileRegex="true" xmlns="http://www.urlrewriting.net/schemas/config/2006/02">
		<rewrites>
			<add virtualUrl="^~/ActualFile/(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/ActualFile.aspx?title=$1" ignoreCase="true"/>
		</rewrites>
	</urlrewritingnet>

That’s it. If you have used another rewriting engine (apache included), this is by far easiest out of the gate. As usual, these are my opinions and my blog. :-) I can make whatever claims I want. LMBO.

#3 feature - Caching
I honestly have never implemented caching beyond adding it to cfquery and I never liked it. At times it was too dog gone harsh with updates. Either way…I’m not going to debate CF caching vs ASP.NET caching. That’s not the point. The point is doing it in ASP.NET was surprisingly simple. I thought it’d be some grueling process.

I didn’t setup the Web.Config so that took a potential nightmare away. I say that because I am not keen on all of the inner workings with Web.Config yet and I am definitely not 100% on Enterprise Library. So, with the Web.Config setup I have the liberty of adding anything I want into cache. Here’s how.

First, include the Enterprise Library files. Second, use the following as a reference.

using Microsoft.Practices.EnterpriseLibrary.Caching;
using KatapultMedia.Kontent.Model.Section;
public partial class Blah : System.Web.UI.Page
{
     private CacheManager mycachemachine;
     private KatapultMedia.Kontent.Model.Section section;
     private int SectionID = 3;

     protected void Page_Load(object sender, EventArgs e){
          if(!Page.IsPostBack){
               mycachemachine = CacheFactory.GetCacheManager();
               section = (KatapultMedia.Kontent.Model.Section) mycachemachine.GetData("MyBlahData");

               if(section == null){
                    section = new KatapultMedia.Kontent.Business.Section().Get(SectionID);
                    mycachemachine.Add("MyBlahData", section);
               }

               mycontrol.DataSource = section.Contents;
               mycontrol.DataBind();
          }
     }
}

Uh oh, what is that stuff about KatapultMedia.Kontent? :-) Yeppers, that is a sneak peak at Kontent, our content management system. More on that later. ;-) Back to the point at hand.

That block of code is a code behind file (example) from the site we’re getting ready to launch. Let me break down what it does. First, setup the CacheManager instance. Second, check to see if the data exists in cache. Third, if it doesn’t, add it to the cache. 4th, bind the data.

The phat part about it is how the cache knows to update the data even though we used custom dll’s for pulling the data. By adding this the page load was DRAMATICALLY improved. I was highly impressed and dang near blown away. This isn’t even getting into output caching. Right now the data is cached and that is it. I can cache the entire page or just a portion of the page. The entire site could be cached piece by piece! SHAWWWEEEEET!

#4 feature - Separate of Code and Design
Aww man..this was soooo refreshing. I truly hate having code at the top of my .cfm’s and .php’s. It is so terribly annoying. The main problem with CF is the extra whitespace at the top. I know…there are ways around it but none are 100% to me. Either way, the code at the top of the file is inevitable, unless you are using some sort of framework that has separation of views, etc.

Having my .cs files handle all data load and binding that data to the controls (custom or otherwise) was so refreshing. For layout I would switch to the .aspx file and make any updates. Then I’d move to my .cs file and do anything I needed there. I truly think the best part is when I used 1 .cs file to power two .aspx files. It was unorthodox (so I was told) but it worked out great. The 1 .cs file kept me from duplicating code. This was pretty nice.

#5 feature - Master Frickin’ Pages!
Oh my! Now this is something you dream of. Forget building some “include framework” that has a “master page” and pulls files based on a url param or otherwise. Build a master and setup your content region(s). Next create a new .aspx file and tell it to use your, just created, master as a base. Now your .aspx file is included in the master, where specified, and you can update 1 (or more) masters to update your entire site layout. This is MUCH cleaner than using includes. If you have used Dreamweaver templates, you understand how sweet it is to use templates. It is just nice. Let’s say you need to add a CSS file to all of your pages. Update your master, upload it to your server, and bask in all that is Master Pages. :-)

#6 feature - Custom Controls
I almost closed this post out until I looked at the sites structure and saw the controls folder. :-) This was highly impressive. Ok…normally you would make an include file and set some variables that your include file would read which would cause it to do certain things. This is the same concept…but sweeter!

An ASP.NET custom control is like a Flex component (mxml specifically). You create an mxml file (your markup) and setup your attributes as needed. This way you can call . It is as simple as that in Flex. Well, ASP.NET is just as sweet. You create a control (.ascx file), insert your markup, set and custom properties, etc in your .cs file (code behind) and your control is done. To use your control you would do the following.

<%@ Register Src="mycontrol.ascx" TagName="mycontrol" TagPrefix="me" %>
...
...
<me:mycontrol myproperty="myvalue" />

That’s it. You have just created a custom control. To establish properties just create a getter/setter for a private variable. Very nice!

Ok…I think it is time to get some work done. Now, I know I said I wouldn’t get long winded but…oh…wait…I said I’d “try not to be long winded” so no apologies here. LOL. I did try. :-)

Anyways, for more info on ASP.NET visit…well…”www.asp.net”:http://www.asp.net. :-) (a very clever url IMO) To clarify 1 point, I am not saying ASP.NET development blows CF out of the water (php, yes; lol). I am merely trying to refute the claims that ASP.NET development is for the birds. If that is true and I am mistaken, call me Big Bird. ;-)

Posted by John C. Bland II on August 22, 2006 8:42 AM |

TrackBack

TrackBack URL for this entry:
http://mt.katapultmedia.com/mt-tb.cgi/203

Comments


nice article. you have barely scratched the surface here … there is so much great features with asp.net, but i have to agree. the #1 feature is absolutley debugging. i dont’ know how i ever lived without it.

Posted by: scott cate | August 22, 2006 9:28 PM


Last night I was thinking about this post and thought “I should have told everyone this is only the surface of what ASP.NET can do.” :-)

Posted by: John C. Bland II | August 23, 2006 11:30 AM


ASP.Net does have a lot of nice features.

Especially if you’re coming from a VBScript / ASP classic world. (my case, back in the day)

Have you played with Ruby on Rails at all?

I had the opportunity about 5 months back to go full-time with RoR.

Rails is missing, from your list:

#1 - there’s no easy way to debug your apps in Rails w/o using the old-fashioned method of log statements. (technically, there is a way but it’s really cumbersome) ASP.Net shines in this area.

#6 - there are a lot of fancy ASP.Net controls you can drop into your pages w/o much effort. Rails lacks this.

Though, Scriptaculous and Prototype go a long way if you are simply doing Ajaxy type stuff like flashing notices/divs, etc.

Posted by: Shanti Braford | September 13, 2006 4:31 AM


Yes, I’ve played with RoR. The most I’ve done is Hello World about 5 times. LOL. I always start then stop and start again. As a refresher I do Hello World over and over just to get my feet wet. :-)

Scriptaculous is great. We are using it on a project right now (PHP) and it is really superb and easy to use. Rails having it integrated is very nice as well. I haven’t toyed with the Ajax features yet but I will have to since I added drag/drop reordering to the project. :-)

Are you a part of the local Ruby/Rails group(s)?

Posted by: John C. Bland II | September 16, 2006 8:16 AM


First things first

ASP.NET - A Framework for developing windows forms applications (oops did I say forms….sorry web) and somehow deploy the whole crap to IIS.

Inability to post to a different page. Who the hell decided that was good idea?

  1. You can only have one “rich” form that ASP.NET can access in a clever and high level way.
  2. Or should I say, accessible in Microsoft Way ;)
  3. Why does MS want to eliminate all client side code from my pages by replacing it with stupid and slow server side code?
  4. Why does every button need to cause a server postback?
  5. Why do I want to validate form input on the server side instead of on the client side with javascript?
    Code you write, or should I say that VS writes, can be written in any other language in 2 lines of code instead of 10, & boy did MS fuck up the data access stuff what crap.

why everything has to be an object with umpteen million properties.

  1. Where they really went wrong is they forget to have a runat=”client” implementation. While they use some javascript to implement there crappy event model, they forgot to think that some developers out there prefer to use javascript with controls a lot.Try accessing/altering an ASP.NET control with javascript?it is possible, but wtf MS?

Please….a humble request

Yep Try Again Microsoft, and this time get some real web developers in on the project from the beginning. AND Not Windows Forms developers.

Posted by: Animesh Saxena | June 8, 2007 1:35 PM

Post a comment