URL Rewrite Module

Today IIS team has made the Go Live release of URL Rewrite Module for IIS 7.0 available for download. This release contains significant functionality and performance improvements and it is believed to have a quality level suitable for production deployments.

Ruslan’s BlogURL Rewrite Module – Go Live release

The type ‘‘ exists in both ‘‘ and ‘

Today I got this error message: "The type ‘<class>’ exists in both ‘<dll location>’ and ‘<dll location 2>’"

I remembered I encountered it before, but I didn’t remember the cause, nor the remedy.  That’s why I keep this blog to post such things that you learn somewhere that, by the time you get the same problem again, you’ve forgotten the solution and you can get back here and help yourself.

I remember I had this error message before, so I went to my own blog searching for the solution, but it wasn’t there.  I either forgot to blog about it then, or it must have been before I started to use this blog as my extended memory.  So now it’s time to store this solution in the extended memory right away.

The reason why you get this problem is that there are 2 dynamically created dll-files defining the same class.  At compile time, there’s no problem, so it must be a problem in the aspx-pages themselves.

I didn’t have time to figure out what the real cause was, but Google came up with 2 forum post which gave me the answer (of course there were more, but why look further?):

ASP.Net Forums and MSDN Forums

The problem with me was that I had a CodeFile="Page.aspx.cs" in the Page directive in the Page.aspx file.  It’s automatically generated when you create a new page, and it didn’t cause me any trouble before.  The only thing I was doing today, was refactoring my base page and master page.  So there must have been some confusion there.

I don’t know wether this is a bug, or my stupid mistake, but anyway, after replacing "CodeFile" with "CodeBehind", everything went back to normal and the pages worked again.

So the next time I receive this error, I know how to resolve it.

Softwaredocumentatie met Sandcastle

[DUTCH:]

Waarom verschijnt er altijd een ongemakkelijke glimlach op het gezicht van een ontwikkelaar als er gevraagd wordt of zijn software gedocumenteerd is? Hoewel deze vraag niet wordt beantwoordt in dit artikel, zal er worden uitgelegd hoe het op eenvoudige wijze mogelijk is om (technische) documentatie van software automatisch te laten genereren.

Atos Application Development & IntegrationSoftwaredocumentatie met Sandcastle

URL Rewriting in IIS 7

I started to use URL Rewriting on a Windows 2008 Server running Internet Information Server 7.  At the time of writing, a technical preview of the module is available here: Using URL Rewrite Module.

After installing the module, I was able to configure a first rule that rewrote an incoming URL in the form of http://server/en/catalogue/123/abc123 to http://server/Catalogue.aspx?l=en&cat=123&sub=abc123, exactly the way I wanted it.

But when opening the page, I saw my layout and styles were gone.  Not difficult to know where the problem is, because stylesheets and images are loaded from the client with their path relative to the requested page.  In this case a reference to "style.css" will be loaded from http://server/en/catalogue/123/style.css instead of http://server/style.css, as the client doesn’t know we’re using URL rewriting on the server.

To get around this problem, several options are possible.  I’ll list few of them here, some good, some even worse.  Of course, these are not the only ones, but these were the ones I looked at to solve my problem.  Other solutions might be even better, so any input and feedback is welcome. My solution is much easier and fits my needs.  It’s posted below the other options.

  1. Override the Render() method of your base page or masterpage: URL rewriting breaks ASP.NET 2’s themes
  2. Use RewritePath Method (String, Boolean) with the second parameter (rebaseClientPath) set to false. (Huh? custom code?)
  3. Move your images and stylesheets out of the App_Themes folder (WTF?): URL Rewriting and folders with dashcommerce
  4. Hardcode your links to stylesheets and images (OMG!)
  5. I’m not going to list any more options as it’s getting worse and worse…

But why don’t you use the power when you’re using the force?

I wrote a rule that is processed before any other rule, and which takes any url pointing to file in an App_Themes folder (or just a stylesheet, which is also possible in the same way):

  • Pattern: ^(.+)/App_Themes/(.+)
  • Rewrite URL: App_Themes/{R:2}
  • and check "Stop processing of subsequent rules"

If you make sure that this rule is processed before the other regular rules by moving it to the top in the ordered list, than all references to theme files (stylesheets, images,…) are correctly served and your layout remains correct.

ASP.Net Load Testing and Optimization Toolkit – So you want to be a hero

One of my passions is optimization. There’s no code related task I like more than making something run better, faster, snappier – from tweaking UI registry keys to stripping out crap code – I want results. Usually if something is noticeably slow on the user’s end, there’s something fundamentally wrong that can be made faster – a lot faster.

PHP vs .NetASP.Net Load Testing and Optimization Toolkit – So you want to be a hero

.NET Developers’ Reference Card Roundup | Alvin Ashcraft’s Morning Dew

I thought I would share this list of reference cards / cheat sheets that I have compiled over the last year or so. If I am missing any good ones, please post them in the comments.

Alvin Ashcraft’s Morning Dew.NET Developers’ Reference Card Roundup

Windows PowerShell Cheatsheet

Windows PowerShell is a modern object-based command shell and scripting language designed for Microsoft Windows. Along with the normal shell features for working with files and programs, it also provides for direct access to all of Windows though the Windows Object Models: .NET, COM and WMI.

This refcard covers starting and using Windows PowerShell, including the syntax for all statements, operators and other elements of the language. Also included are examples of how to use .NET, COM, ADSI and WMI objects from PowerShell. Finally, it includes tips and tricks—short examples showing how to perform common tasks from PowerShell.

DZone RefcardzWindows PowerShell

Exception handling best practices in ASP.NET web applications

Exception handling plays an important part of application management and user experience. If implemented correctly it can make maintenance easier and bring the user experience to a higher level. If not, it can be a disaster.

How many times have you seen the error message that doesn’t make any sense or at least provides some valuable information, or even better – how many times have you seen the famous error screen with exception message and a complete stack trace on yellow background? Too many times, I would say. This is why, among other things, some of my colleagues were very interested in exception handling techniques and best practices.

The goal of this article is to provide an overview of what exception handling is from the user perspective and the perspective of people who maintain the application, and to show the best practices of how to implement useful error handling in ASP.NET web applications. This article is related to my previous articles CSS Message Boxes for different message types and Create MessageBox user control using ASP.NET and CSS since this two articles describes how to show user-friendly messages.

Janko At Warp SpeedException handling best practices in ASP.NET web applications

Testing IE Versions Just Got a Little Easier

Testing your sites on different versions of Internet Explorer has always been notoriously difficult mainly due to the fact that Microsoft prevents you from running to different versions of the browser in Windows. Sure there have been solutions to get around this limitation but in my experience, they’ve always caused unexpected results and instability for the operating system or required you to run a VM. Not ideal.

AjaxianTesting IE Versions Just Got a Little Easier

Google Doctype – Google Code

Google Doctype is an open encyclopedia and reference library. Written by web developers, for web developers. It includes articles on web security, JavaScript DOM manipulation, CSS tips and tricks, and more. The reference section includes a growing library of test cases for checking cross-browser and cross-platform compatibility.

Google Doctype is 100% open.

* Open source
* Open content
* Open to contributions from anyone

Google CodeGoogle Doctype

(Better) JQuery IntelliSense in VS2008 – BradVin’s .Net Blog

I know, I know, this has been done before. The reason I’m writing this post, however, is to improve on what I have found on the web. For anyone wondering what jQuery is, goto the jQuery site and also read this tutorial. Now onto the good stuff….

If you are like me and you’ve read the many articles about how to get other javascript libraries to work in VS2008, you’ll know that all you really need to do is install the visual studio HOTFIX. This patches your VS and among other things, gets the javascript intellisense working nicely.

BradVin’s .Net Blog(Better) JQuery IntelliSense in VS2008