.net session timeout in IIS6
March 26, 2009 | Leave a Comment
Does this sound simple web.config setup?
Nope this is way beyond that newbie configuration.
Problem: We were facing timeout issue on one of our servers. Web.config settings had no effect on the time out.
Note: In all screen shots pink color is hiding the actual server details.
Solution:
So here are some more interesting findings related to timeouts of sessions in IIS6 hosted on a windows 2003 server. You may need to change one or more of these setups in your server according to your setup.
There are totally 5 setups that influence your timeout. All of those are discussed here.
1. Web.config file of Application: First one to influence timeout is Session timeout setting in your we.config file.
Note: Web.config file is inherited to the subfolders and subfolders config settings take the precedence in case they exist.
2. Application session timeout in IIS:
Go to IIS, right click on the web application, go to properties. Go to Directory tab, click on Configuration button. Application configuration tab opens, click on Options tab as in the screenshot, you will find enable session state. Change the session time out period here.
3. Default website session timeout in IIS: Right click default web site under IIS and choose Home directory tab. Click on configuration button to open application configuration. Choose options tab and you will find Enable session state again similar to session state of each application. Enter higher session timeout period which will be application to all sites in the webserver.
4. Change Worker process idle timeout of application pool – Shutdown worker process after being idle for (time in minutes) – Default is 20 minutes. This setup is applied for all websites that use this application pool. To change this, Right click on the required application pool, choose Performance tab, and change the duration of idle time or uncheck the option so that the process is never recycled. You can also create an application pool, configure it, and use it for a selected list of web applications.
5. Change Recycle timeout period of application pool: Right click on application pool or default application, and choose Recycling tab. Change the “Recycle worker process (in minutes)” option to either change the period or disable the option by un checking. Un checking this option may be a good idea from performance point of view.
And finally there is a last one in machine.config file. But that does not affect any of these configurations and these setups take the precedence.
Usage of SOS.dll to measure object size
March 2, 2009 | Leave a Comment
Make sure ‘enabled managed debugging’ is checked in the project properties.
Add the directory where SOS.dll is located to the PATH environment variable,
which is in the (C:\Windows\microsoft.net\framework\v2.0.50215)
At a breakpoint, in the immediate windows, execute :
.load sos.dll
!help (shows a list of debugger commands)
Common ones (for looking at GridView objects as example):
!DumpHeap – type GridView
!DumpObj 0×00a8197 (or whatever address)
“Access Denied” when ASP.Net accesses Eventlog
March 2, 2008 | Leave a Comment
The ASP.Net applicatin returned an “Access Denied” error when it was accessing the eventlog.
I couldn’t help jumping on this too since it was blocking. I was pretty sure it’s not the GPO’s fault at the very beginning because the GPO hasn’t been used here yet. The identity for the App pool was the “Network service” account. Thus I
checked the security settting for the event log:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
\Application\CustomSD
I added a WRITE access for the “Network service” account: (A;;0×2;;;NS). It didn’t work. Then I checked web.config and found the site was using “impersonation” and basic authentication. I added (A;;0×2;;;AU) for authenticated users, the site started to work again.
What the heck is (A;;0×2;;;AU)? You can check out Microsoft’s weirdo SDDL (Security Descriptor Definition Language) at MSDN or here
How to debug web applications with Firefox
December 28, 2007 | Leave a Comment
Debugging is one of the most painful parts of developing web apps. You have to deal with browser inconsistencies with HTML, CSS and javascript, let alone the difficulty of debugging javascript itself.
Here’s a rundown of the Firefox extensions I use to manage this madness.
Taming CSS: Web Developer Toolbar
Install Web Developer Toolbar. Just do it.
Debugging CSS can be really frustrating. The Web Developer Toolbar lets you inspect and edit (in real-time) the HTML and CSS of your page, so you can see what’s happening when things don’t line up. It can do a heck of a lot more, but here’s what I use it for:
Ctrl + Shift + F: Display element information. This puts a red box under your mouse. Move the mouse over an element and its attributes appear in a pop-up: the name, class, pixel sizes, fonts, everything. Here’s what you can do:
- Figure out what classes are creating the styles you see
- Easily get the div’s id for use with Firebug (below)
- Figure out how big an image is (pixel height and width)

Ctrl + Shift + E: Edit CSS. This pops open a sidebar tab with the current stylesheets. You can edit any attributes and see the effect in real-time (like giving Google a black background):

My favorite CSS style is border: 1px solid red;
I’ve done the following hundreds of times during the course of web development:
- Find a div with your mouse (ctrl + shift + f)
- Get its id
- Edit CSS (ctrl + shift + e)
- Put a border on the div: #mydiv{border: 1px solid red;}
- Play with widths, heights, margins and paddings until it lines up nicely
- Remove the border
But rather than deleting the border, put an “x” in front: “xborder: 1px solid red”. The CSS won’t be valid so the border is ignored, but keeps the style around in case you want to enable it later.
Select all the text in your edited CSS file and paste it into the real CSS file. Bam, your changes are now live. It’s almost the reverse of creating a file in DreamWeaver and viewing it in Firefox. You are viewing the live file in Firefox, making changes, and copying those back into your text editor. I’ve found this very effective for editing CSS, you avoid the constant back-and-forth switching because Firefox now has a CSS editor.
Bonus: ColorZilla Picks Colors
ColorZilla gives you a dropper that can find the hex RGB value (#123456) of anything on the page. This is great when designing, and you want to match a font color to a color in your page. This is way faster than taking a screenshot and opening it up in Photoshop.
Keeping Javascript In Line: Firebug
Firebug, how I love thee. If you love yourself you will install it immediately and save countless hours of frustration.
Firebug can debug javascript, examine the DOM, and do much more (you can and should read all about it). Here’s how I use it:
F12: Open Firebug. You may have to enable it for the page.
Console Tab: Write quick javascript commands — it even has autocomplete on variable names and properties. Play around with your functions, change CSS attributes, add elements to the page — whatever it takes to test.
Script Tab (Debugging): Best. Feature. Ever. Click on a line number to set a breakpoint (red dot) in your javascript. Reload the page and it will break (pause) when it encounters the line.
At this point, you can switch over to the console to examine and change variables, and figure out what the heck is going on when your code won’t work. You can then hit the blue “play” button and continue running your app, until the next breakpoint.
Net Tab: Find the download performance of your page.
Profile Button (on Console Tab): Find the run-time performance of your page. Click “profile” to begin capturing information, do some commands, and then click stop. You’ll get a report of where your code spends its time. If you must optimize, optimize the common-case first.
If you are a more visual person, try this awesome collage:

Not satisfied? Check out the examples on the home page.
Dive into the details: Live HTTP Headers
Sometimes you need to dive into the nitty-gritty. What cache headers is my site sending back? Are my pages really gzip-encoded?
I know these questions keep you up at night, so here’s what you can do:
1. Install Live HTTP Headers
2. Open it (Tools > Live HTTP Headers)
3. Visit a page / press refresh
4. Rejoice

As you visit a page, you’ll see HTTP headers fly by as your browser requests elements. If items are cached, the browser may not request them at all (awesome!) or may request the element and get a 304 “Not Modified” response (slightly less awesome, you still had to check with the server). I’ve written more on cache behavior, and Live HTTP Headers is a great way to learn about HTTP caches (something every webdev should be interested in for performance reasons).
Even better, you can “replay” any header, editing the data that is sent. This is useful when testing or debugging cache or gzip encoding behavior.
Debugging IE: The lost chapter
Argh, unfortunately IE lacks these wonderful tools. There is a script debugger, but it doesn’t hold a candle to Firebug. In fact, I often just resort to alert statements, which make you shudder after being spoiled by Firebug.
One less painful method I use is this:
In your HTML: <div id="log"></div>
In your Javascript:
function log(str){
var log = document.getElementById("log")
if (log){ // let's be safe...
log.innerHTML += str + "<br/>";
}
}
Usage: log("Hi there!");
It’s nothing fancy, just a simple logging function that appends text to a div. Yes, it’s brutal, but it’s better than alert() statements, especially if you have a loop (unless you like repetitive stress injuries or want to condition yourself to fear dialog boxes). If anyone knows a good way to debug javascript in IE I’d love to know. The tools I’ve tried have been very clumsy and disjoint, taking you out of the browser.
I try to do 95% of my development in Firefox, and debug IE-specific issues (like erratic substr behavior) using this method.
Keep Getting Better
Web Developer Toolbar and Firebug can do way more than I’ve described here. Like the 80/20 rule, these are commands I use most frequently that give me the best bang for my buck. Take a few minutes to learn these tools and you’ll save hours down the line. And here’s a few more tools for web development.
These tools might not save you from getting a nervous twitch in one eye from building web apps, and that’s ok. They’ll save you from getting that twitch in both.

