août 31

Let's imagine you have a standard application deployed in IIS (here, the "MyApp" application). Simply browsing the application will show you the default page content, and you can also access any page of the website.

Now let's imagine you want - for maintenance reasons for example - bring this application offline.
If you stop IIS or your application pool, all your customers will receive an HTTP error, typically a 500 error. Let's imagine you want to have real "maintenance page" whatever the request they will do.
Of course you can change the "default" document in IIS, but if they ask for a specific page, this won't work.

IIS has this feature fully integrated. Simply add a page named "app_offline.htm" in the virtual directory and let's try now several requests, asking either for the virtual directory itself or for any page in the application.

This is pretty cool no ?
Just note that this will work if the client ask for aspx pages. Any other format will be served normally.
Scott Guthrie has also noted that you maintenance page should have a minimal weight otherwise, you would encounter some trouble. Check his blog entry here.


Working another way for maintenance sessions ? Please leave comments !   

Tags: |
août 27

Hello,

a few time ago we were needing to update a website IIS' parameters to add some mime types.
In order to do that, we must use two COM components that you can find in %windir%\system32:

  • Active DS IIS Namespace Provider  (adsiis.dll)
  • Active DS Type Library                   (activeds.tlb)

We won't deal here how to add some mime types to IIS by code but how to create wrappers around these COM DLLs to be able to use them in .NET.
Of course, you all know that we can just "Add a new reference" to our project to let Visual Studio create these wrappers for us.
Article finished.

Not completely. Indeed if you do that and that you compile, you will see  bunch of warnings (40 in fact) like for example :
      The type library importer could not convert the signature for the member 'ADS_OCTET_STRING.lpValue'.
      The type library importer could not convert the signature for the member '__MIDL___MIDL_itf_ads_0000_0002.lpValue'.
      The type library importer could not convert the signature for the member 'ADS_NT_SECURITY_DESCRIPTOR.lpValue'.
      ..........

If you are like me, no warning is acceptable in a project and so we have to do it differently. Of course in this case, there is no way for us to correct these warnings, but maybe we can hide them by creating the COM wrapper ourselves
To achieve this, we will use "tlbimp.exe" which is located in "%programfiles%/Microsoft Visual Studio 8/SDK/v2.0/bin" or in the corresponding folder depending of which version of Visual Studio you use.
To simplify our command lines, we'll update the %path% environment variable to include the tlbimp path, and we'll run a command prompt into "%windir%\system32".

Step 1 : Generate the ActiveDs.dll
As this DLL is referenced by adsiis.dll, we'll start by this one. Note that we want to specify that we are not interested by any warning

      tlbimp activeds.tlb /out:c:\temp\Interop.ActiveDs.dll /silent
 
Note that this command line use the type library file (activeds.tlb) to generate the DLL. We'll generate it in the temp directory and we'll keep the name that is normally generated by Visual Studio

Step 2 : Generate the AdsIis.dll

In this case, we'll specify that it references "Interop.ActiveDs.dll" and we'll also specify the main namespace of the DLL. We have chosen the namespace that is generated by Visual Studio.

      tlbimp adsiis.dll /out:c:\temp\Interop.IISOle.dll 
                           /reference:c:\temp\Interop.ActiveDs.dll /namespace:IISOle

Step 3 : Use the DLLs

Now you have two valid DLLs that can be used by any .NET project. And due to the "/silent" flag used in Step 1, no more warning is shown in Visual Studio.


Question:
Experts, do you know another way to achieve to the same result ? But maybe without using a command line ?

Tags:
août 23

A few days ago, we have made an XP meeting in the company to let all people in the team (developper, analyst, tester, ...) express their feeling, what was working good or less good, what we should impoove, ...
And one developper has said that. For him, in XP, "each developper must have its own bottle of water".
I will try here to reformulate (and translate) what he has said.


"For me, in XP and in pair-programming, it's important that each developper has its own bottle of water.
A few years ago, I was working with handicaped people and we have done an exercise one day, asking to valid people to seat on the wheel-chair and so be at the place of handicaped people. One assistant/helper was doing what he has always done with handicaped people, pushing them in the house. What was happening ? At the first turn, the assistant turned in one direction as he has always done, and the "fake handicaped" was so surprised as he was expecting the turn. Later on, arrival on stairs and starting to climb them. The guy was simply astonished and afraid.

Let's stop the exercise, and do it again, differently, asking to the helper to always speak and explain what he was doing before doing it.
Now we will turn to the right. The "handicaped" guy was of course not surprised. Let's now climb the stairs. Ok no problem.
What's the point of that ? When you speak and explain what you do, or what you want to do, the other guy is never lost and can follow you easily without any surprise and without any fear.

And the parallel with Pair-programming ? Of course we won't compare one of the two developpers with being handicaped, but one of the two is not typing and thus doesn't know the minds of the writer and can be surprised (and easily lost) by what is colleague is now doing.

To avoid this kind of situation, it's important to have each people in the programmer pair speaking a lot of what they are currently doing and their idea, what is their goal, how to achieve it. It will lead to a good cohesion between each developper and the team will be more concentated and efficient.

Of course, as we must all speak a lot, we'll get thirsty and so, we each need our own bottle of water."

 

I find this example quite interesting because it represent the feeling that the copilot is having sometimes, not knowing where the pilot wants to go. So let's all speak more ! (in a productive way!)

Tags:
août 21

I have been asked many times why I use this provocative subtitle.
Pretentious? Far from that.
Time to answer :-)

I often compare .NET to a big encyclopedia of thousands of volumes, among which we know only 1, 5, 10 or 20 volumes depending of people. The biggest problem is that this encyclopedia grows by several brand new volumes each year. Thus - if we have stopped learning, as many developpers tends to do after university - our knowledge ratio tends to decrease with the time.
And in a way, this knowledge ratio is our value on the work market. What is the commercial value of a developper with  2 years experience in .NET 2.0 and not being able to explain the very basis of generics ?

I believe that currently - or in the (I hope near) future - we are able to do what we want to do in .NET. Some parts are very easy, some completely crazy, to make you feel becoming insane, but still feasible for some experts, having a specific domain expertise.
And when we can't do something, what we miss to achieve this work - easy or difficult - is knowledge, Simply knowledge. Of course frameworks or tools may help us to achieve more easily the work, but with extra knowledge, we could do it, by ourselves.
And that's exacty the point. What is feasible for a few experts, is not for other developpers.


Our domain is huge and no-one on earth will know all of it. And so in a way, because all of us is missing knowledge in the "technically feasible area" we are all incompetent. Some more than others, but we are all incompetent.
But the truth is, some experts are working, and working hard, to become less and less incompetents. By less incompetent, I mean to reduce the field of their unkown knowledge.
And these same experts also work, and work hard, to help other developpers following them.
Difficult race of learning quicker (and deep enough) than the new functionnalities arrival.

This sentence I use is far from being pretentious. All the contrary.
I want to let remember people, and more specifically to let remember me, that I still miss lots of knowledge.
I want to have this idea firmly rooted in my mind "Work and Work hard. Learn and Learn deep! There are so many things you could still learn!"

Tags:
août 20
A few days ago, Loïc Bar (http://www.loicbar.com/) has posted a new feed to explain how to customize an ASP.NET application using master pages (and how to store this value in the user profile).
As added in the feed comments, I wanted to react to go a bit further.
Indeed this is typically an AOP problem that may (should) be adressed with AOP. You can find here the original post of Loïc Bar.
And you can download here my article explaining how to achieve the same goal using HttpModules in ASP.NET. This article will be my reference one for when speaking - later on - of HttpModules, as it shows, step by step, how to create it and how to handle it.