July 2008 - Posts
You have GOT to be KIDDING me...after the asp.net guys went crazy and posted a lot of great AJAX control toolkit tutorials, the silverlight guys have posted FIFTY TWO (yes 5 and 2) videos on silverlight 2 beta 2.
Downloading 'em now...oh why do I have a slow internet :(
As I mentioned in my last post, I've finally given urlrewriter.net a try - just to get over my php faithful friends who always sneered at us for those .aspx extensions.
I watched this video: How Do I: Implement URL Rewriting? by Scott Golightly. While it was good for the basic stuff (and informative), you'd have to code everything by hand. Also,near the end, he shows an implementation of a custom Form class that can handle postbacks with url rewriting. This has the major drawback of having to change the form tags on every page, and also having to register the control on every page....i.e. it's messy. The actual implementation also seems to totally remove the action on the form entirely. Of course, as asp.net forms submit to themselves (non-MVC), I don't know how big a problem this is.
Anyhow, I went on over to the Gu's tutorial - something I have been wanting to do for ever so long. I did everything according to method three. Everything worked as expected...except for images. If I created some redirect rules that traversed folders (i.e. www.site.com/folder/page rewrites to www.site.com/home.aspx?f=folder&p=page), sometimes the themes and images were loading, sometimes they weren't (depending on the rewrite rule). As ScottGu mentioned on his blog, making images have absolute paths helps; but themes seem to cause a problem with more complex rules.
So, I thought for a bit and added this little rewrite rule to the mix:
<rewrite url=".*/App_Themes/(.+)" to="~/App_Themes/$1" />
What this does is that it takes any request to anything with App_Themes in the url and maps it to the root App_Themes folder. So, no matter what the level of nesting, and no matter what rewrites are used, anything I the App_Themes folder will work perfectly. This works perfectly with themes. And as an added bonus, relative urls like "App_Themes/theme1/image.png" (as opposed to absolute urls like "~/App_Themes/theme1/image.png") will also work for images, css files, etc. And if you don't like the App_Themes folder, you can always add a rewrite for another folder using the same technique as above.
Needless to say, for this to work, you'll need to map every request to asp.net (just as you need with extensionless urls). This is damn easy in IIS7, and tougher on IIS6, as ScottGu points out.
So, there you have it, a simple hack that makes themes and resources work in perfect harmony with url rewriting. Can't wait to show my php religious friends. And just to add insult to injury, I made an asp.net page specifically for them:
http://Heartysoft/LookAtThisAspxPageYouMoron.php
Can't wait till they wake up and log onto the LAN ;)
What a coincidence...my second post on my blog is also about Kaspersky. Why do I keep running into the weird things? Anyway, this should also hold for many web content filters.
Last night I was finally playing around with the most excellent urlrewriter.net. I'm on IIS7 on Vista x64 SP1. I'd always thought (for unknown reasons) that this thing would be tough and would give me a headache with my images and stuff. I followed the Gu's awesome tutorial over here , and as usual, the hard thing became easier (thanks Scott). I wanted extensionless urls and I had IIS7 - just to get over my php faithful friends who always sneered at us for those .aspx extensions.
Well...I added the reference, created the form control provider, hooked it up with the browser file and put the stuff needed in web.config. It worked great, except for themes. More on that in my next post.
Well...great except for one thing: everything was turning out exactly as I wanted after initial tweaking (again, next post), but for some god forsaken reason, the three images that make up my site banner were not getting displayed. They displayed fine when browsed through the VS dev server, not so after deploying to IIS.
This took a few hours of hair pulling, as I could see no logical reason why it'd display bucket.png, but not banner.png. I even tried putting an image tag of the files on the page. Nope. Didn't work. And worst thing was that there wasn't even a red cross. How could the browser "find" the file (no red cross), and yet display nothing?
I created another test site, this one without urlrewriter.net. Same problem. Banner_left.png displays when viewed from the dev server, doesn't when viewed from IIS.
Another whole hour, and for some reason, I thought of my dear old friend and protector, Kaspersky. I go into settings>>content filtering. I see that Banner Add Blocker is running. I see I have nothing under white lists and blacklist. I click the link 0(total 0). And sure enough, I get displayed a LOT of default filtration rules. Quite a few rules are dedicated to remove anything and everything that has anything remotely connected to the specific word "banner" (ban, banners, bann, bannerz...). I go to the whitelist tab and add "localhost". Everything works :)
In the end, I decided to change the images' names, as I highly doubt any Kaspersky user would actually add my site to their whitelist to see my site banner. Still, if you're having similar trouble with your web filtering software, I hope this helps. It would've certainly saved me a few hours of playing around with IIS settings.
I'm finally starting off this blog about a month after Joe gave it to me...yay, awesome, yahoo (or should that be MS yahoo?).
One thing that has always frustrated me was that whenever I install Vista (or XP), everything is zippy and fast. Gradually, things become really sluggish. Then, it becomes so unbearable that I have to reinstall the darned thing. The thing that slowed down the most (or at least, is a frontline contender for slowing down) seemed to be VS - the one thing I needed the most (well, maybe after IE). This really was getting on my nerves, and I blamed it on my hardware. So imagine my surprise when, after a recent upgrade, it seemed even zippier than before, but the sluggishness "somehow" returned. Now don't get me wrong - when I say "upgrade", I mean a total renovation - a quad core Q6600, 4GB of DDR2-800MHz (5-5-5 timings to boot), 2 10Krpm Western Digital Raptors in RAID 0, HD 3870 and a Thermaltake PSU that broke my back as well as my bank - some of the best things I could buy back in last September (the HD3870 was bought later). And then I found the culprit.
I've always loved Kaspersky, awesome little thing. But, like any other antivirus, it likes to check every opened file and make sure it's safe. This is all fine and good, but I don't think there's anything lurking inside my .cs files just waiting to pounce on my system. So, I go ahead and add VS to my trusted stuff, give it full permissions, and tell Kaspersky to not even monitor files opened by VS or any of VS's activity. And guess what, it's been months now, and VS is still as zippy as when I first installed Vista. I went ahead and put some other obviously-not-virus-carrier programs into my safe zone, and they work like a dream, too.
I always thought that turning the antivirus off for VS wouldn't give me "that" much of a boost since I had some kick-ass hardware. Boy was I pleased to be proven wrong. I installed Vista x64 in February, and not a single frustrating moment since then.
I use Kaspersky, but the principal should hold for all other virus guards if they have a trusted apps feature or something.
Hope that helps.
More Posts