Robots.txt HttpHandler in IIS7

Nathan Totten on November 06, 2008

In a ongoing effort to automate more of my work I decided to build a HttpHandler for IIS that automatically creates my robots.txt files. This particular handler will create robots.txt files that block all search robots. This handler will be installed on our projects web server which is used for development purposes only, and as such we don’t want these pages being listed in search engines.

First, we create a class project in visual studio. Next, add a reference to System.Web. Then create one class titled RobotsHandler.cs and add the following code.

Capture

Next, we need to strongly sign the assembly. This is required because we are going to add this assembly to the GAC on our web server. See this link for instructions if you are not familiar with this concept. http://msdn.microsoft.com/en-us/library/xwb8f617.aspx

Now that our little class library is completed we need to build. Remember to change the compilation to Release. Now, copy the assembly to the web server and register it in the GAC. See this link for more details on using gacutil. http://msdn.microsoft.com/en-us/library/ex0ss12c(VS.80).aspx

After the assembly has been registered, we will register the handler in IIS7. See this link for instructions on how register a custom handler. http://technet.microsoft.com/en-us/library/cc753249.aspx. Remember to set the path of the handler to “robots.txt”. This will intercept all requests to robots.txt and map them to your new handler.

Now, test to make sure everything worked correctly using your web browser. Go to http://www.mysite.com/robots.txt. You should see this text:

User-agent: * Disallow: /

You could definitely expand this to use custom rules from a database or configuration file. You could also set the file to allow all robots by changing “Disallow: /” to “Disallow:”.

Related to:


Photo Box Rotator

Nathan Totten on October 06, 2008

I have created a JavaScript photo rotator similar to the one on iStockPhoto.com's home page. This rotator is pretty simple and only requires about 20 lines of JavaScript. You can see an example here: http://www.solanocoallition.org. This sample was built using ASP.NET and does use a few functions from the ASP.NET AJAX Library. You could easily change it to whichever library you use or don't use.

First we setup the containers to hold the images:

Capture1

Next, is the JavaScript:

 Capture2

There are a few nice features about this rotator. First, the images are completely random. Second, one pane will not switch images more than one time before another pane rotates. Third, there will never be duplicate images displayed at the same time.

A few things to note. First, you could remove all of the hard coded images in the HTML and just build them dynamically the first time the function is run. This would cut down on some the HTML. I chose to do it this way in case there was an error on the client or if the user has JavaScript disabled. This way they will still see static images rather than an empty space.

You can download the code here: http://www.atlasbay.com/filestorage/imagething.zip

Related to:


Email Security

Nathan Totten on January 28, 2008

I just ran across a great tool to help you verify the identity email senders. This tool is called iconix (http://www.iconix.com/). Basically, this company has teamed up with companies like PayPal, Wells Fargo, Netflix, and about 350 others to provided verification of the email addressed. So, if you receive an email from your bank, say Wells Fargo, iconix will validate that email to ensure it is legitimate. It is very simple and easy to use. It is compatible with almost every major email service and software. Best of all it is completely FREE for the end user. Try it out and let me know your experience.

Related to:


ASP.NET 3.5 Extensions CTP Released

Nathan Totten on December 11, 2007

I downloaded and tested the new ASP.NET 3.5 Extensions today. There are many new and exciting features in the CTP. My favorite is the MVC (Model View Controller) Framework and its accompanying tools. The MVC framework is a complete 360 from traditional ASP.NET forms pages in a number of ways. First, there is a very clear separation of the layers of your ASP.NET web app. Second, you will notice the HTML output of a MVC app is extremely clean. There are not viewstate or other hidden tags among other things. Third, and probably most important, is the page life cycle is very different. While ASP.NET MVC is built on top of System.Web many events from the old System.Web.UI.Page class are not fired inside the new ViewPage class.

From a application development standpoint I think this new framework will help developers and designers work better together. I don't have to worry much about what goes into the .aspx page and the the designer doesn't have to worry about dependencies in my code. ("Is it okay to change this datalist to a repeater?") As a developer I am only responsible for passing objects into ViewData. The designer can insert these values wherever they please. For example, lets say I make a simple have a PersonController with the action Person. This action accepts an id value. So the url might be http://www.example.com/People/Person/32. Using my DataContext from my SQL to LINQ I use dc.GetPerson(id) to retreive a single person. From there I simply use RenderView(string viewName, object viewData) to render the view and pass the person object to ViewData. The Person object will be automatically placed into the ViewData dictionary and be accessible on the view using ViewData["FirstName"] for example.

sc2[6] 
The controller.

sc3
The view.

The end result is a very maintainable piece of software, a very nice URL for the end user and clean HTML output. It will be interesting to see how this project progresses and how we can fit this into our software at Atlas Bay.

Related to: mvc, asp.net


Windows Vista Service Pack 1

Nathan Totten on December 07, 2007

Today, I downloaded Windows Vista Service Pack 1 Release Candidate and my first impressions of the changes are good. There are not many user interface changes, but the performance issues and annoyances are noticeable. The one user interface change is most notable is the removal of the search button from the start menu. To clarify, this isn't the removal of the quick search box as some had though. The search box is still there and very easy to use. Another change in search is that third parties, such as Google, can now build their search tools right into Vista. In terms of performance, I noticed a few things right away. First, copying files and folders was MUCH better. This was one of the biggest annoyances of Vista, and it appears to be fixed. I haven't played around with this long enough to notice if program stability is improved, but I never really had a problem with that pre service pack 1. There are other improvements in the areas of security and more back end stuff that the user won't really notice, but are still important. Overall, I think this is a good step forward for Windows Vista especially for businesses who have been holding off.

Related to: windows vista


Copyright © 2008 Atlas Bay Technology Coporation