Lions Den

The Code and Times of Hanan Schwartzberg

About Hanan | Hanan's CV | Contact Hanan

October 19, 2010

Visual Studio 2008 – ASP.NET “System.Runtime.InteropServices.COMException”

Filed under: ASP.NET,IIS7 — Tags: , — Hanan Schwartzberg @ 4:01 pm

The Issue

When openning an existing ASP.NET project for the first time in Visual Studio 2008 it returns the error “System.Runtime.InteropServices.COMException” without any HRESULT code. The problem I experienced was specificly on a Windows 7 machine, but the same solutions should work on Vista as well.



April 18, 2010

IIS7.5 “HTTP Error 500.19 – Internal Server Error”

Filed under: IIS7 — Tags: , , , — Hanan Schwartzberg @ 10:33 pm

The symptom

After loading an ASP.NET web application on an IIS7.5 server, navigating to the site resulting in the following error:

HTTP Error 500.19 - Internal Server Error

The search for a cause and a solution

The first step was this Microsoft KB Article that breaks down the 500.19 error based on the HResult: Unfortunately, for the HResult above, 0x8007000d, the only cause listed is “a malformed XML elemen” in the web.config. After spending some time looking at the web.config I came to the conclusion there were no malformed tags.

The next solution I found was from JohnnyW on ASP.NET, JohnnyW’s error was evidently caused by Ajax not being properly installed. He includes this link on how to configure AJAX for ASP.NET. Since, due to some old controls we do require the AJAX 1.0 extensions to be installed I made the changes to the web.config it recommends, but still kept getting the same error.

I decided to manually hunt for the cause in the web.config and so I started to remove sections one at a time until the error disapeared and the site loaded.

The actual cause and soluion

The section that was actually causing the error was the rewrite section.

    <rule name="Redirect to www" stopProcessing="true">
      <match url=".*" />
        <add input="{HTTP_HOST}" 
            pattern="^$" />
        <add input="{HTTP_HOST}" 
            pattern="^$" />
        <add input="{HTTP_HOST}" 
            pattern="^$" />
      <action type="Redirect" 
          redirectType="Permanent" />

Searching for information on redirect rules led me to, where he explains you can use URL Rewrite “by installing the URL Rewrite Module.” This was what actually caused the 500.19 error. The server didn’t have the url rewrite module installed. I solved the issue by downloading the IIS URL Rewrite 2.0 from here: and installing it. Instantly the 500.19 error was cleared up.

February 17, 2010

IIS7 Sessions Getting Crossed / Mixed Up / Copied

Filed under: ASP.NET,IIS7 — Tags: , , — Hanan Schwartzberg @ 10:25 pm

The symptom

Users reported seeing data that did not belong to them when they logged into their accounts. Logs showed that nearly 10% of our users were being assigned copies of other users’ sessions. The entire session object was copied, including the sessionVariables and sessionID. Once duplicated the individual sessions could be modified without affecting the other (i.e. abandoning one did not kill the other).

To spot instances of the problem I stored the Request.RemoteHost (The IP address of the computer making the request) in a sessionVariable. At the beginning of each request I checked to make sure the session’s IP matched the current request’s IP.

What is was not

It is possible that the IP would change naturally, most simply if a user reset his router/modem. This was not the case because it was happening way too often. Further, there were confirmed instances of one user’s data being crossed with another’s. Finally, some of the pairs of IPs weren’t just on different computer, but were in different countries.

It is also possible, and was often suggested, that sessionVariables can stop being unique if they are used with static/shared variables within the WebApp. This was not the case either, because the IP address I stored in the session was only written to once, from the request and afterwards was only read to compare back to the request. This was also ruled out because the SessionID was also duplicated and that is a read only value.

What is was

It is a feature/bug in IIS7. This latest version of IIS introduced some new caching features.

  1. IIS7 automatically caches static content, such as HTML pages, images, and style sheets.
  2. IIS7 now has the ability to cache dynamic content as well.

Caching dynamic content is great if it is a page such as a dynamically generated image gallery, or a page that is generated dynamically based on the browser’s culture. However, in this thread,, Anil Ruia, a Senior Software Design Engineer on the IIS Core, explains, “You should not be enabling output caching for any response which depends on session state.”

If the page generating the content depends on the session state, it caches the session object along with the rest of the page. The next user to come through ends up pulling the cached session, instead of getting a new one. When I checked our settings I found it was set to cache all .aspx pages for three minutes, including many pages that access the session.

The solution

Edit Cache Rule

In IIS7, disable the caching for .aspx pages in any directory with an page that depends on the session state. To do this:

  1. Run the Server Management console.
  2. Navigate to Roles -> Web Server (IIS) -> Internet Information Services.
  3. Select the site you wish to modify.
  4. Select the folder that contains the .aspx pages you need to turn caching off for.
  5. In the Feature View, double-click “Output Caching”.
  6. If there is a rule there already for the .aspx extension double click it. Otherwise right click and select “Add…”
  7. Enter .aspx for the “File name extension”
  8. Check “User-mode caching”
  9. Select “Prevent all caching”
  10. Check “Kernel-mode caching”
  11. Select “Prevent all caching”
  12. Click OK
  13. Close the Server management Console

October 26, 2009

Why the scrollbar won’t show on the left in Firefox

Filed under: CSS — Tags: , , , , — Hanan Schwartzberg @ 7:56 pm

The Scenario

When designing a website for a right to left (RTL) language the scrollbar should automatically be on the left hand side. The logic is that it should be at the end of the line, just as it is on the right for a left to right (LTR) language. This works fine in IE, but Firefox will always show the scrollbar on the right.

The Cause

Unfortunately this is by design. Firefox believes that the scrollbar is part of the browser, not the webpage and so by default a website should not have the ability to override the user’s settings. IE believes the scrollbar is not part of the browser but part of the page. Therefore, if a page is RTL the scrollbar should be on the left.

The Solution

This can be fixed on an individual instance of Firefox.

  1. Open Firefox
  2. Navigate to about:config
  3. Set the filter to layout.scrollbar.side
  4. Double click the layout.scrollbar.side line
  5. Change the setting to 1 and click OK

Now Firefox will behave like IE and show the scrollbar on which ever side the page dictates. Unfortunately, this will not help any of your users. The best solution to assure your RTL website displays the scrollbar on the correct side is to use a third party customizable scrollbar, such as jQuery Scrollbar or jScrollPane.

October 11, 2009

WUMP – Website Uptime Monitor Program

Filed under: C#,Utilities — Hanan Schwartzberg @ 1:17 am

Click here: to download the WUMP from its CodePlex page.

WUMP Settings

What is WUMP?

After a frantic call from a client who found her site was down due to a server issue, I decided I needed a way to regularly monitor the sites I consult for. WUMP, the Website Uptime Monitor Program, is the resulting solution. Written in C# 2008, WUMP is made up of three projects.

  1. AutoWump – A windows service to control the automated WUMPing, or testing, of sites
  2. SledgeHammer – A class library that does the actual work
  3. wump – A Windows application for customizing the settings, starting and stopping the AutoWump, and running manual tests.


  • Automatically monitor the status of multiple websites at a set interval
  • Manually check the status of multiple websites
  • Test site statuses without affecting Google Analytics
  • Maintain a log of test results
  • Send an email alert if a test fails

How WUMP works:

In order to test the site without affecting the Google Analytics add a file to the root path of the site. The name of the file is configurable. By default it should be named “wump.html”. The file can simply be an empty page:


When a site is WUMPed, the program attempts to download the target file. If it encounters an error the test fails. A log is kept of all test results in a text file, by default “c:\wump.log”. In the event of a failed test result WUMP has the ability to send an email via SMTP.

Where to get WUMP:

WUMP is available as an open source project on CodePlex here:

September 10, 2009

CalendarExtender Plus

Click Here to download the latest version of CalendarExtender Plus and documentation.

The CalendarExtender Plus is a modification of the calendar extender that ships as part of the Ajax Control Toolkit. There are two main features added to the control. First, you can limit the selectable dates to a specified date range. Second, there is now the option to show an alternate header. The new header includes two DropDown Lists, one to select the month and one to select the year.


August 25, 2009

Show a Wait Message While Waiting for Postback to Complete

Filed under: ASP.NET,Client Side — Tags: , , , , — Hanan Schwartzberg @ 10:13 am


Among the controls on a page is an update panel with a button that when clicked causes a partial postback that takes at least a few seconds. During this time you want to show the user a wait message that will disappear as soon as the postBack completes.


August 12, 2009

Default a TabContainer to No Tabs Selected


Under normal circumstances when a page loads with a tabContainer on it one tab must be selected. The selected tab can be specified via the ActiveTabIndex property. What if the tabContainer needs to default to an empty tab with none of the tabs selected?


Add a dummy tabPanel to the tabContainer and leave it blank. Use the pageLoad JavaScript function to hide the tab’s header

<cc1:TabContainer ID="TabContainer1" runat="server" 
    Height="200px" Width="200px" ActiveTabIndex="0">
    <cc1:TabPanel runat="server" ID="tpDummy" HeaderText="">
    <cc1:TabPanel runat="server" ID="tpName" HeaderText="Name">
            <asp:TextBox runat="server" ID="txtName" />
    <cc1:TabPanel runat="server" ID="tpEmail" HeaderText="Email">
            <asp:TextBox runat="server" ID="txtEmail" />
function pageLoad(sender, e)
    var objTpDummy = 
        document.getElementById('<%= tpDummy.ClientID %>' + '_tab'); = 'none';

August 10, 2009

Show a Wait Message While Generating a File for Download

Filed under: ASP.NET,C# — Tags: , , , , — Hanan Schwartzberg @ 1:31 pm


A page has a list of images for the user to choose from. When a file is selected the request is processed via an AJAX call that directs the source of an iFrame to another page where the image is generated and passed back to the client.

Due to the size of some of the images, the generation can take a noticeable amount of time. To make sure the user does not think the site is frozen a wait message is needed. Since the generating page only returns the image, we need another way to notify the client when the file is generated and the wait message can be hidden.


June 16, 2009

Introducing CalendarExtender Plus

Maximum Date - May 15th, 2009
Click Here to download the latest version of CalendarExtender Plus and documentation.

The CalendarExtender Plus is a modification of the calendar extender that ships as part of the Ajax Control Toolkit. There are two main features added to the control. First, you can limit the selectable dates to a specified date range. Second, there is now the option to show an alternate header. The new header includes two DropDown Lists, one to select the month and one to select the year.

The available dates can be limited using the MaxDate and MinDate properties.

<cc1:CalendarExtenderPlus runat="server" ID="cepExample" 
    MaximumDate="01/01/2009" MinimumDate="5/15/2009 />

Setting the ShowDdlHeader to true will show the heading with dropDownLists to select the month and year.

<cc1:CalendarExtenderPlus runat="server" ID="cepHeaderExample" 
    TargetControlID="txtExample" ShowDdlHeader="true" />


The Calendar Extender Plus has a few other enhancements, including the ability to show or hide the arrows in the heading to move back and forth a month, and a property to show or hide today’s date at the bottom of the calendar.

Since the CalendarExtender Plus is a modification of the standard extender it has all the properties and functionality of the original. It can be skinned using the normal css, and automatically fills the textBox with no need for additional javascript.

The CalendarExtender Plus is free to download, use, and distribute with your project. Any feedback is greatly appreciated!

« Newer PostsOlder Posts »
Home | Site Design | Banner Design | Code Den | Offsite Posts | Downloads | Photography | About Hanan | Hanan's CV | Contact Hanan
Copyright © 2009 Hanan Schwartzberg. All rights reserved.