Wednesday, March 26, 2008

HTTP requests from the future


These days I'm working on a DotNetNuke (DNN) based Portal development. Our development env is IIS 5.1/XP while our deployment env is IIS 6/Win 2003. During our past 2 deployments we encountered a strange error on IIS 6/Win2003. Soon after the deployment every page in our portal solution spits a java script error 'Sys is undefined'. This is an error related to the ScriptManager.js which is needed in Ajax pages. There were dozens of google search results for this error pointing fingers to IIS, web.config file settings, axd file handlings, Ajax java scripts etc...but we just couldn't figure out the solution quickly enough. After a late night struggle we gave up and decided to check it the day after. When we came and check next day, the problem has got fixed by itself overnight :).

I always know when problems starts to get fixed by themselves it's a warning sign for worst things ahead. But I just could not reproduce the problem to study it that day. So we went happily in to our final deployment yesterday and here we again had the good old error 'Sys is undefined'. This time around we dig down and went in to analyzing this in depth. When we looked at the HTTP response for a page 2 requests for a ScriptResource.axd files were having HTTP 500 codes. (Read about .axd files here ). When I used fiddler to analyze the HTTP response in detail we caught up with the message
"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.Parameter name: utcDate". Eureka!!!

Now we knew that the problem has to be something to do with the time. In every ScriptResource.axd request there are 2 parameters being sent. Eg : ScriptResource.axd?
d=8fBiB6-cb_63xIkOjfdl6BCL-uzAt8lEaJgT8GHfNac0VUzhoOSl_j9ebDYDA0Ao0
&t=633420390180000000
The 'd' param is relevant to data it is asking for and the other 't' reflects the time which the resource was built. (Use this tool to decrypt axd requests). The problem was that our win 2k3 servers time was not accurate and it actually resided in the past ( A few hours). Thus the axd request was seen by the server as requests coming from something which was built in the future.
After the problem was identified the root cause finding was not difficult. Our win2k3 time synchronizing service had a problem. Now we were able to think back and understand why this problem got fixed on it's own the last time :). The problem just slept over it till the server time difference was consumed. Isn't that a nice way to solve problems....just sleep over it :)

Sunday, March 09, 2008

Continuous Documentation cont...

As it usually happens, after going through all the troubles to have a continuous documentation happening (see previous post) in my project I found out a much easier way to achieve the same. While the previous post concentrated on purely using the native sandcastle xsl files to apply several xml/xsl transforms using Nant, the new easier method will rely on the very useful tool 'Sandcastle Help File Builder' or SHFB as it's also known. You need to download and install SHFB in both your local machine and the build machine. ( It would be better to breeze through my previous post before you go through this)

Let me run through the simple steps involved in this method.
1. Open up SHFB in your local machine and configure it to generate the documentation to your project.
2. Some important steps in configuring the SHFB are,
  • Adding the assembly and the documentation xml (Generated from the Nant -doc attribute as mentioned int he previous post) for documentation
  • Adding the dependent assemblies needed to build the main assembly
  • Choose the helpfile format (I choose Help2xAndWebSite)
  • Set HtmlHelp2xCompiler Path (Where you have installed HTML Help Workshop, see previous post)
  • Set output path
3. Build the SHFB project and let the documentation to generate
Now you will have the documentation files (html, chm) in your local machine, which is not our target. We want the documentation to build periodically, automatically in our build machine. Patience....2 more steps.
4. Now save your SHFB project and you will find a SHFB configuration file. Get it copied to your build machine.
5. Now include the following task tag in to your ccnet documentation project (other project tags are not mentioned here) and you are ALL SET to have continuous documentation running in your project.

<tasks> <exec> <executable>C:Program FilesEWSoftwareSandcastle Help File BuilderSandcastleBuilderConsole.exe</executable> <baseDirectory>D:WorkDirSandcastleWorkDirSPNPortalDocumentation</baseDirectory> <buildArgs>"D:WorkDirSandcastleWorkDirSPNPortalDocumentationDocumentationSettings.shfb"</buildArgs> <buildTimeoutSeconds>10800</buildTimeoutSeconds> </exec>

</tasks>

Pay attention to the 'buildArgs' element where you specify where the shfb configuration file can be found.