A couple days ago I made a blog post about a simple HTTP handler written in ASP.NET. The purpose? To spit out 404 errors for .css file requests on CSS Naked Day. That handler will undoubtedly work great, but it does have one minor maintenance-related flaw. Each year you will have to update the constant date value to be accurate. Granted, that is a simple task, but it still requires time and a little bit of effort. Dustin Diaz left a comment notifying me of a nice JSON file sitting out on GoogleCode that I could tap…
[ Read More ]UPDATE: I have came up with a better zero-maintenance solution thanks to a comment by Dustin. The one bellow will still work, you just have to maintain the date constant that is defined at the top of the handler.
I kinda like the idea of CSS Naked Day, which was thought up by Dustin Diaz (a Google fellow) a couple of years ago. I have decided to participate. If you have a personal web site, I would encourage you to do the same. If your web site runs on ASP.NET (highly recommended), you can use the HTTP handler below. I wrote it today and am implementing on my blog. On CSS Naked Day, which is defined at the top of the handler in a constant, it will return a 404…
[ Read More ]I spend alot of time surfing the Internet. Who doesn't? When I come across an outgoing link (when I say outgoing, I mean a link to a page that resides on a different domain), I always have to make a decision. As an end user, I am clueless as to whether or not the link will open up in a new window. Perhaps the browser is to blame for this. Regardless, I don't usually take any chances, so I right-click the link and choose to open it in a new window/tab. Every potentially suspicious link (most of them are) requires at least two clicks. I have reached the point that I do this instictively, without even thinking about it. I honestly feel the browser should be responsible for telling the user which links will be opened externally, and perhaps there should also be settings in place for the user to specify how they want all links to behave, depending on anchor tag attributes such as target="_blank" and rel="external". It doesn't take long before you realize…
[ Read More ]So… I was watching a classic film called Bio-Dome today, and I couldn't help but notice that an actor in that film looks exactly like Scott Guthrie! I was expecting this feller to start yip-yapping about the glorious benefits of ASP.NET, but then I realized that I was not watching a podcast…

That screenshot is at about 13:38 into the movie. Am I crazy, or does this guy look exactly like ScottGu?! Alright, so the real Scott isn't that bald, but still. This guy could show up at a developers conference and get numerous…
[ Read More ]I decided to sign up for Twitter the other night for no reason at all. I have used it a few times since then, and I can appreciate the whole social networking aspect of it. However, I can't help but conclude that this the most idiotic thing that I have ever signed up for. I just don't understand the purpose of writing several short messages throughout the day. Are you going to return several months later to see what you did on Feburary 28th? Oh, and it's totally unstable and slower than molasses! After Googling about it, I noticed on Wikipedia that it is written in Ruby on Rails. LMAO! That explains why the site is down RIGHT NOW!
Another thing worth mentioning is the poor site design. It literally took me four or five clicks just to locate a textbox that I can enter a name to search. When I naturally click "Find &…
[ Read More ]If your ASP.NET application calls a web service (you have a reference in your App_WebReferences folder), you might come across this fairly typical System.Net.WebException. I have seen two different breeds of this exception, and the solutions for each of them are quite similiar. I will start off with the most common of the two.
The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
This is the one you are most likely to see, and the fix for this is simple and generally well-known. You need to create a class that inherits your web service class. Then you simply override the GetWebRequest function and modify the KeepAlive HTTP header accordingly…
[code snippet]
Simple as that. When you need to invoke the web service elsewhere in your code, just instatiate that class instead of what you would do normally…
[code snippet]
And that…
[ Read More ]I am not sure why you would want to do this, but I have seen the question asked on the ASP.NET forums a couple of times so I figured I would post a solution for it. It is not that difficult to create a "Save As…" button on your web page that, when clicked, will prompt the user with a download dialog containing the rendered markup of the page. All you have to do is have a button that will refresh the page, except append a query string to it. Then in the Page_Load you can check for the existence of the query string and change the content type and disposition of the response to trigger the dialog.
First, add the following markup where you want it on your page…
[code snippet]
All that is doing is adding a query string to the existing URL and redirecting to it. Add this code in the Page_Load to check for the query string…
[ Read More ]I know it has been kinda quiet around here lately, and tonight I finally got some time to post a solution to a legendary web application problem (I also rolled out a few updates to my blog, as you may have already noticed). The issue at-hand probably gets most of its exposure through the use of the ASP.NET framework. On a web form, it is often a requirement to prevent multiple form submissions to maintain efficiency and avoid complications on the server-side. The most visually appealing way to accomplish this is by disabling the submit button as soon as the form submits, essentially stopping the user from going on a clicking spree. Seems like such a trivial task, but unfortunately doing it the normal way will cause problems.
The Problem
When an HTML form gets submitted, an HTTP POST is automatically generated and shipped off to the form tags "action" value. This POST data…
[ Read More ]Have you ever been typing up an email in Outlook and accidentally hit the Ctrl+Enter keyboard shortcut? This will send the email immediately in Outlook 2003. This happened to me the other day at work; I was pasting a screenshot into the email (I used Ctrl+V because I heart keyboard shortcuts) and I pressed the Enter key to go to the next line and continue to compose my message. But, since I type at the speed of light sound something fast, I had pressed enter before I completely let off the Ctrl key. The window just vanished, and the email was sent! Fortunately my life was not ruined, but it dawned on me how such a simple chain of events could turn out to be a major tragedy. Imagine if the email was very important, and you sent it prematurely. That could be very embarassing, it all depends. But the fact that it could be scared me a little, and…
This is another minor annoyance I have been noticing alot lately. When linking to a fragment (section) on a separate page, sometimes the browser will not properly scroll to the fragment. The cause is the prematurity of the scrolling action. If the browser were smart (Opera is), it would wait for images to load before scrolling to the fragment. If you have no clue what I am talking about, then let me explain. On the front page of ScottGu's blog, you will see that each blog post has a link to the comments section on the left side of each post title. Most of the times when you click that link, it instantly drops you down to the coments section, and by the time the abundance of screenshots load the comments are not even on the screen anymore.
It's annoying. I don't think it would be a problem if CSS were used to set the dimensions of each image, but not all content…
[ Read More ]