Thursday, 29 October 2009

Hiding configuration sections from nested ASP.NET apps

If you have an ASP.NET website nested under another in IIS, you will likely get a server error unless both sites have exactly the same dependencies. This is because IIS, by default, applies web.config settings hierarchically to sub-sites. You can use this fact to your advantage, to prevent you having to repeat the same settings in the child site's web.config.

However, often, you will need certain configuration settings to apply only to the parent site. To restrict specific web.config sections to apply to the parent application only, wrap the relevant sections in the parent site's web config file within:

<location path="." inheritinchildapplications="false">
// your configuration sections
</location>

You can have as many of these location tags in your web.config as you like.

Note: Visual Studio 2005 will throw an error on the inheritInChildApplications attribute. To get round this you will need to add your location elements to web.config after you publish the site (or use VS 2008)

Thursday, 9 April 2009

MS SQL Server How To - Creating relationships in a database diagram

This one had me scratching my head for 5 minutes, so I thought I would share it.

If you want to create relationships in your SQL Server 2005 database diagram:

  1. Right-click the table that contains the foreign key (FK) in the forthcoming relationship.
  2. To create the relationship, click the ellipsis (...) box to the right of "Tables and Columns Specification". (This is quite hard to see.)
  3. In the Tables and Columns dialog, you can now select the tables, FK, and PK (Primary Key) that will participate in the relationship.

Have fun!

Monday, 19 January 2009

Empty div height issues in IE6

Sometimes your website will need to use empty divs for display purposes - e.g.: showing an image to make the top/bottom of an element look curved.

Typically, you would use an empty div, and set it's background image in css; but for floated or cleared elements, height is ignored. IE6 assumes that the element has text inside it, causing it to be slightly taller than the curved-top bg-image.

To correct this, explicitly set font-size:0; in css for the element with the curved bg-image.

Note - you must use an end tag to avoid any problems with the left or right padding. E.g.:

<div id="container_top_curve"></div>