<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Care, Share and Grow! : ASP.Net</title><link>http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx</link><description>Tags: ASP.Net</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>A simple exe to find DEBUG build for managed modules and DEBUG attribute in Web.Config for Web applications in IIS 6/7</title><link>http://blogs.msdn.com/saurabh_singh/archive/2009/12/05/a-simple-exe-to-find-debug-build-for-managed-modules-and-debug-attribute-in-web-config-for-web-applications-in-iis-6-7.aspx</link><pubDate>Sat, 05 Dec 2009 22:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9933033</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/9933033.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=9933033</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=9933033</wfw:comment><description>&lt;P&gt;&lt;FONT size=1&gt;CAVEAT: Some stories before I get to the point, so you may want to skip to the end.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;We in Microsoft PSS get lot many cases on a daily basis which are related to performance issues with Web applications developed using ASP.Net and hosted on IIS. Based on my experience with debugging these issues many-a-times I have seen that one (or two) very basic step is often missed by our customers. Guess what, they develop the projects/class libraries/modules/assemblies etc (name it whatever you want) and test it thoroughly in the development/testing/staging environments and then go ahead and deploy the same binaries in the Production. What they overlook or tend to forget is that they are deploying the same DEBUG build modules/dlls in the production as against the recommended RELEASE builds/dlls.&lt;/P&gt;
&lt;P&gt;Most of us know that for performance reasons it is always recommended to deploy a release build in the production as against a debug build to reap more benefits from compiler optimizations etc. The above observation is generic and applies to any application running managed code. &lt;/P&gt;
&lt;P&gt;There is one more thing people often overlook when it comes in specific to IIS ASP.Net Web applications, i.e. DEBUG attribute in the Web.Config file under system.web/compilation tag. This is one setting which has a lot of repercussions on the performance of the Web applications running ASP.Net as a web technology like memory issues, fragmentations, etc.&lt;/P&gt;
&lt;P&gt;A very nice detailed tutorial by &lt;A href="http://www.dotnetscraps.com/" target=_blank mce_href="http://www.dotnetscraps.com/"&gt;Rahul&lt;/A&gt; (one of our former Technical leads in IIS/ASPNET support group) just reflects what I will never be able to convey any better. Check this &lt;A href="http://aspalliance.com/1341_The_Infamous_DebugTrue_Attribute_in_ASPNET.all" target=_blank mce_href="http://aspalliance.com/1341_The_Infamous_DebugTrue_Attribute_in_ASPNET.all"&gt;link&lt;/A&gt; if you want to know more on how this DEBUG attribute may affect your application.&lt;/P&gt;
&lt;P&gt;What we often do in support is that we capture memory dumps of the IIS process and analyze it using various tools (most common here being WinDBG). There are some public extensions available to our customers like sos.dll to debug managed memory dumps. However this extension has been deprecated (from .Net 2.0) and it does not have a feature to find out debug modules that were loaded in the IIS process and the value of the debug attribute set in the Web.Config file.&lt;/P&gt;
&lt;P&gt;I felt that getting memory dumps from our customers and then finding out the above in their application settings and then recommending them to fix it just adds to the overall delay in finally fixing their core issue. This should be done by default. This is something that does not even need our support in the first place if people are well aware of it. &lt;/P&gt;
&lt;P&gt;I wrote this tool just to help reduce their downtime or getting one step closer to their ultimate resolution. I know I write a lot so I will come straight to the point now :).&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT size=3 face="Comic Sans MS"&gt;Point:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;EM&gt;Feature 1:&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This tool (I rechristened it as &lt;EM&gt;DebugFinder.exe&lt;/EM&gt;) will attach non-invasively to any currently running process on the system and find out if any managed modules that are loaded is a DEBUG or a RELEASE build. This is applicable to any process and not only to Web applications. That way you can find out at run time which managed modules referenced in the current process are deployed as release versus debug builds. This helps keeps track of any debug build assembly that is being referenced from the GAC at runtime apart from the modules loaded from its current working directory if any. Once done it then detaches from the attached process without terminating it.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Feature 2:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;We know that it is always recommended to have DEBUG attribute set to false in a Web.Config file in a production server.&lt;/P&gt;
&lt;P&gt;This tool scans the machine for the Web applications that are configured in IIS. It looks for the Web.Config files corresponding to all the web applications configured in IIS and checks if they have the DEBUG attribute set to true or false and notifies in the display. &lt;/P&gt;
&lt;P&gt;The Debug flag checking in the Web.Config file works for the web applications running either in IIS 6.0 or IIS 7.0/7.5 by this tool.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT size=2&gt;Pre-conditions:&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;DebugFinder has to be run locally on the machine where we want to get the debug related details (remotely may be in another version). &lt;/LI&gt;
&lt;LI&gt;It needs .Net framework 2.0 to be installed on the machine for successful running. &lt;/LI&gt;
&lt;LI&gt;Currently it is designed/tested for Win2k3/Vista/Win2k8/Win7 for finding Debug attribute in the Web.Config file. &lt;/LI&gt;
&lt;LI&gt;If we have UAC turned on on Vista/Win2k8/Win7 ensure we run it in the privileged mode. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Here are some screenshots:&lt;/P&gt;
&lt;DIV style="OVERFLOW-X: scroll; OVERFLOW: hidden"&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Mysimple.ConfigforWebapplicationsinIIS67_D339/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Mysimple.ConfigforWebapplicationsinIIS67_D339/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Mysimple.ConfigforWebapplicationsinIIS67_D339/image_thumb.png" width=1137 height=130 mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Mysimple.ConfigforWebapplicationsinIIS67_D339/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Mysimple.ConfigforWebapplicationsinIIS67_D339/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Mysimple.ConfigforWebapplicationsinIIS67_D339/image_4.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Mysimple.ConfigforWebapplicationsinIIS67_D339/image_thumb_1.png" width=640 height=449 mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Mysimple.ConfigforWebapplicationsinIIS67_D339/image_thumb_1.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here I have used MdbgCore.dll to attach/detach to a process at run time and show the details for debug modules. &lt;/P&gt;
&lt;P&gt;Attached is a zip file, containing a 32bit and a 64bit DebugFinder builds along with MdbgCore.dll. Ensure we keep both the DebugFinder32/64.exe and the MdbgCore.dll in the same folder while running it.&lt;/P&gt;
&lt;P&gt;Chill!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9933033" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/saurabh_singh/attachment/9933033.ashx" length="258734" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Microsoft+Support/default.aspx">Microsoft Support</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/.Net/default.aspx">.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Tools/default.aspx">Tools</category></item><item><title>Required permissions when calling a Web service using client certificate for authentication in an ASP.NET Web application</title><link>http://blogs.msdn.com/saurabh_singh/archive/2009/07/03/required-permissions-when-calling-a-web-service-using-client-certificate-for-authentication-in-an-asp-net-web-application.aspx</link><pubDate>Fri, 03 Jul 2009 04:08:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9815515</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/9815515.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=9815515</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=9815515</wfw:comment><description>&lt;p&gt;A Web service requiring Client certificate authentication is a common scenario.&lt;/p&gt; &lt;p&gt;You may have a client application which needs to send the Client certificate as part of the web request for accessing the web service.&lt;/p&gt; &lt;p&gt;This client application may be a Windows/Console application or another Web application.&lt;/p&gt; &lt;p&gt;Often you will get into issues wherein you are able to send Client certificate as part of the web request from a windows/console app but not from another web app. The primary reason for this could often be around Web app not being able to send the client cert to the target Web service.&lt;/p&gt; &lt;p&gt;This can happen for multiple reasons, in particular account under which Web app is running doesn't have enough permissions to access the Client cert in its local certificate store.&lt;/p&gt; &lt;p&gt;Refer to this excellent &lt;a title="901183" href="http://support.microsoft.com/?id=901183" target="_blank"&gt;kb&lt;/a&gt; for this for more details.&lt;/p&gt; &lt;p&gt;In this post I want to highlight ways in which you can grant access to the Web application account to access the Client certificate in its local machine store.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;When we have to send client cert as part of the web service call from a web app we need to ensure that the client cert is installed in the Local Computer -&amp;gt; Personal Store on the local box (where Web app is running). By default you will see the client cert installed in the Local User Store for the user who requested and installed the cert on the machine. You need to ensure first that the client cert is installed on the Local Computer Store instead of the Local User Store and then follow any of the methods below to grant access to the private key for the account (under which your web app is running).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Method 1:&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The above article &lt;a title="901183" href="http://support.microsoft.com/?id=901183" target="_blank"&gt;kb&lt;/a&gt; gives an example of granting access using the &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=c42e27ac-3409-40e9-8667-c748e422833f&amp;amp;displaylang=en" target="_blank"&gt;Microsoft Windows HTTP Services Certificate Configuration Tool&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;b&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;b&gt;&amp;gt; WinHttpCertCfg.exe -g -c LOCAL_MACHINE\MY -s " &lt;var&gt;IssuedToName &lt;/var&gt;" -a " &lt;var&gt;AccountName &lt;/var&gt;"&lt;/b&gt;&lt;/p&gt; &lt;p&gt;for e.g. &lt;/p&gt; &lt;p&gt;&lt;b&gt;&amp;gt; WinHttpCertCfg.exe -g -c LOCAL_MACHINE\MY -s " &lt;var&gt;IssuedToName &lt;/var&gt;" -a "Network Service" &lt;/b&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;There are other ways in which you can achieve the same result. This feature is in fact built in on Windows Server 2008 within the Certificate mmc console.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Method 2:&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Using the WSE X509 Certificate tool (This tool has features that can be used to check certificate properties).&lt;/p&gt; &lt;p&gt;You need to &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=1ba1f631-c3e7-420a-bc1e-ef18bab66122&amp;amp;displaylang=en" target="_blank"&gt;download&lt;/a&gt; Web Services enhancements (WSE) 2.0+ SP3 for Microsoft.Net and in the install wizard ensure you select Tools as shown below:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/4e6e8ea9250e_4A38/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="381" alt="image" src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/4e6e8ea9250e_4A38/image_thumb.png" width="504" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Once installed go ahead and launch the tool. It has a clean UI. You have the option to check certificates in the Local Computer/Current user for the available stores like Personal/Trusted/Intermediate Root CA etc. If you click on View Private Key File Properties (shown below) you can directly modify the permission for private key associated with the certificate. Basically this is just a file under &lt;em&gt;C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys&lt;/em&gt; on Win2k3 server and&amp;nbsp; &lt;em&gt;C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys&lt;/em&gt; on Win2k8 server.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/4e6e8ea9250e_4A38/image_10.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="539" alt="image" src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/4e6e8ea9250e_4A38/image_thumb_4.png" width="551" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;You may want to go ahead and give the Service account under which the web app is running Full permission on this file (modify the permissions from the Security tab).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Method 3:&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;If you are running the web app on Windows Server 2008/Vista there is a far simpler way built in the Certificate mmc.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/4e6e8ea9250e_4A38/image_12.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="312" alt="image" src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/4e6e8ea9250e_4A38/image_thumb_5.png" width="572" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Right click on the certificate and go to All Tasks -&amp;gt; Manage Private Keys and then give Full permission for the associated account.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Till next time..&lt;/p&gt; &lt;p&gt;Cheers!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9815515" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Client+Certificate/default.aspx">Client Certificate</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Troubleshooting/default.aspx">Troubleshooting</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Setup/default.aspx">Setup</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Windows+Server+2008/default.aspx">Windows Server 2008</category></item><item><title>Visual Studio 2005/2008 IDE: Web Controls in the Toolbox seen grayed out for Asp.Net projects ?</title><link>http://blogs.msdn.com/saurabh_singh/archive/2009/04/23/visual-studio-2005-2008-ide-web-controls-in-the-toolbox-seen-grayed-out-for-asp-net-projects.aspx</link><pubDate>Thu, 23 Apr 2009 03:28:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9563619</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/9563619.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=9563619</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=9563619</wfw:comment><description>&lt;p&gt;Here is a quick post that may help you save few hours if you get into this problem.&lt;/p&gt; &lt;p&gt;&lt;u&gt;Symptoms&lt;/u&gt;&lt;/p&gt; &lt;p&gt;-- Out of blue you realize that when you try to create and open a new Web&amp;nbsp; site/Web Application project we do not see any of the Web controls in the Toolbox. It includes most of the sections in the Toolbox pane including Common controls, Data, Login, validation and in fact any of the controls which are associated with an Asp.Net web page.&lt;/p&gt; &lt;p&gt;-- When you click on 'Show All' in the toolbox you see all the Asp.Net related controls grayed out. In fact you will see most if not all, of the sections in the toolbox being grayed out except HTML controls.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/8ee2548b9714_6F3/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="409" alt="image" src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/8ee2548b9714_6F3/image_thumb.png" width="331" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Go to the Source view for the Web form in the VS IDE and add an ASP control yourself like &amp;lt;asp:TextBox...&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;/p&gt; &lt;p&gt;Browsing to the web page shows the control getting rendered without any issues. So seems like more of a VS IDE issue than anything to do with ASP.Net application configuration.&lt;/p&gt; &lt;p&gt;-- Creating a new Winform project works fine with all the relevant controls being displayed and working in the Toolbox window.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;Resolution&lt;/u&gt;&lt;/p&gt; &lt;p&gt;This issue may happen if by mistake you had associated ASPX pages with the HTML Editor in the VS IDE. It should be ideally associated with the Web form Editor.&lt;/p&gt; &lt;p&gt;To resolve this, In the Solution Explorer, locate the ASPX that we are working on, right click on the page and select 'Open with...'.&lt;/p&gt; &lt;p&gt;You may be seeing that the current selection is HTML Editor (Default). Change it Web Form Editor and click on 'Set as Default'.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/8ee2548b9714_6F3/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="366" alt="image" src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/8ee2548b9714_6F3/image_thumb_3.png" width="564" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Close the current VS IDE and re-launch it and now we should *hopefully* be good.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9563619" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Automate client certificate one-to-one mapping in IIS 6.0 using C#</title><link>http://blogs.msdn.com/saurabh_singh/archive/2009/04/11/automate-client-certificate-one-to-one-mapping-in-iis-6-0-using-c.aspx</link><pubDate>Sat, 11 Apr 2009 03:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9544308</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>23</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/9544308.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=9544308</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=9544308</wfw:comment><description>&lt;P&gt;In PSS, we occasionally get requests from our customers wherein they want to automatically add entries for client certificate mapping in IIS or Active Directory (AD). That is either a 1-to-1, Many-to-1 or AD mapping for the client certificate authentication for the web site. I recommend going with AD mapping because that eases the management but it finally depends upon one's need.&lt;/P&gt;
&lt;P&gt;I am not sure but I feel there is a security breach plus annoyance when an administrator has to laboriously enter the mappings for all the accounts/certificates (I am being specific to 1-to-1/Many-to-1 here). &lt;/P&gt;
&lt;P&gt;The concern I feel when dealing with the administrator doing it for 1-to-1 and Many-to-1 are:&lt;/P&gt;
&lt;P&gt;a. If there are hundreds of users you need to do this manually for everyone of those accounts and it's a pain.&lt;/P&gt;
&lt;P&gt;b. Yes, the above can be automated using a script but then the second concern that arises is that whoever is running the script has to know the passwords for all these accounts to be mapped. I think this doesn't sound good.&lt;/P&gt;
&lt;P&gt;I have written a sample application using which users can enter the mappings themselves in the IIS's Client certificate setting, i.e. entries having the client certificate mapped to a windows account (either a local IIS or AD account) and the corresponding password. &lt;/P&gt;
&lt;P&gt;So this is how it works:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;User accesses this web page from their workstation which already has the client certificate installed. 
&lt;LI&gt;They are authenticated over Basic with SSL. 
&lt;LI&gt;Browser sends across the client certificate as part of the HTTP web request. 
&lt;LI&gt;This application gathers the user account, password plus the client certificate from the incoming HTTP web request and does the mapping in IIS.&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/b5fb3b4c2db3_3557/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/b5fb3b4c2db3_3557/image_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=760 alt=image src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/b5fb3b4c2db3_3557/image_thumb.png" width=617 border=0 mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/b5fb3b4c2db3_3557/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I am adding the code here in case someone may want to extract the section for automated scripting instead of using it as a web app.&lt;/P&gt;
&lt;P&gt;This code is also attached to this post as well.&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4"&gt;
&lt;DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.Data;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.Configuration;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.Web;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.Web.Security;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.Security.Cryptography.X509Certificates;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.Web.UI;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.Web.UI.WebControls;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.Web.UI.WebControls.WebParts;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.Web.UI.HtmlControls;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; System.DirectoryServices;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt;/* This sample application is to automate One-to-One Client certificate mapping in IIS 6.0.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * User should be able to access this site from the browser and select the client certificate&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * in their machine which will be mapped to their account on the IIS server for 1-to-1 mapping. &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * You need to deploy this application on the IIS server which is hosting the website(s) which &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * needs client certificate mapping, preferably under its own virtual directory.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * Important:&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * - Have the authentication for this web application configured to use Basic along with SSL.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * - Have the "Accept client certificates" or "Require client certificates" selected under &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *   &amp;lt;Website&amp;gt; -&amp;gt; Properties -&amp;gt; Directory Security -&amp;gt; Secure communications -&amp;gt; Edit -&amp;gt; Client certificates&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * - Ensure the website that we want the mapping for is mentioned in the web.config file associated with&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *   this application under &amp;lt;appSettings&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * - In the Web.config file we are impersonating an Administrator account for this application. &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *   &amp;lt;identity impersonate="true" userName="Administrator" password="myadminpassword"/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *   This is done because non-admin users cannot modify the IIS metabase. If you do not want users to map&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *   entries themselves through web page you can change this to &amp;lt;identity impersonate="true" /&amp;gt;.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *   In such a case only admins can add the mappings for their user accounts. Non-admins won't be able to &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *   add the client mapping entries.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *   This is valid for both domain or local Windows NT accounts.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * - This app is written using .Net 2.0, ASP.Net 2.0 and above in mind. You should be able to make it work&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *   with ASP.Net 1.1 as well.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * - You may prefer to run this application under its own dedicated application pool to ensure stability and security.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; * DISCLAIMER: The code is not tested for production scenarios so use it at your own risk. &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *             In case one wants to use batch scripting etc or some kind of console app instead &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; *             of web app you can extract the code section from this page which should work fine for the job.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt; */&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;partial&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt; _Default : System.Web.UI.Page &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;{&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;protected&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; Page_Load(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; sender, EventArgs e)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;      {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;B&amp;gt;Client Certificate One-to-One Mapping Application:&amp;lt;/B&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"Serial number: "&lt;/SPAN&gt; + Request.ClientCertificate.SerialNumber + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/BR&amp;gt;&amp;lt;HR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"Issuer: "&lt;/SPAN&gt; + Request.ClientCertificate.Issuer + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/BR&amp;gt;&amp;lt;HR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"Subject Name: "&lt;/SPAN&gt; + Request.ClientCertificate.Subject + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/BR&amp;gt;&amp;lt;HR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (Request.ClientCertificate.IsPresent)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"Validity&amp;lt;BR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;Not before: "&lt;/SPAN&gt; + Request.ClientCertificate.ValidFrom + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/BR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;Not after: "&lt;/SPAN&gt; + Request.ClientCertificate.ValidUntil + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/BR&amp;gt;&amp;lt;HR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;B&amp;gt;There is no client certificate sent along with the request!&amp;lt;/B&amp;gt;&amp;lt;HR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"Authenticated User: "&lt;/SPAN&gt; + Request.ServerVariables[&lt;SPAN style="COLOR: #006080"&gt;"AUTH_USER"&lt;/SPAN&gt;] + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/BR&amp;gt;&amp;lt;HR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"Authentication Type: "&lt;/SPAN&gt; + Request.ServerVariables[&lt;SPAN style="COLOR: #006080"&gt;"AUTH_TYPE"&lt;/SPAN&gt;] + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/BR&amp;gt;&amp;lt;HR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;    }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;protected&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; Button1_Click(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; sender, EventArgs e)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;    {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; user = Request.ServerVariables[&lt;SPAN style="COLOR: #006080"&gt;"AUTH_USER"&lt;/SPAN&gt;];&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; password = Request.ServerVariables[&lt;SPAN style="COLOR: #006080"&gt;"AUTH_PASSWORD"&lt;/SPAN&gt;];&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; clientCertMappingName = &lt;SPAN style="COLOR: #006080"&gt;"Mapping for "&lt;/SPAN&gt; + user;  &lt;SPAN style="COLOR: #008000"&gt;// &amp;lt;--- Our One-to-One Mapping name for the entry&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        HttpClientCertificate cert = Request.ClientCertificate;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #008000"&gt;/*&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt;          If you want to map a client certificate located on the disk instead of the one as part of the &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt;          HTTP Web request try the code below.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt;          &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt;          X509Certificate certificate = X509Certificate2.CreateFromCertFile(@"c:\cert.cer");&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt;          X509Certificate certificate = cert.Certificate;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt;          byte[] certHash = certificate.GetRawCertData();&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: #008000"&gt;        */&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;byte&lt;/SPAN&gt;[] certHash = Request.ClientCertificate.Certificate;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;try&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #008000"&gt;//Get the name of the Web site for which mapping has to be done from the App settings in the web.config file.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; friendlyWebsiteName = ConfigurationManager.AppSettings[&lt;SPAN style="COLOR: #006080"&gt;"websitename"&lt;/SPAN&gt;].ToString();&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #008000"&gt;//Get the Site Identifier based on the friendly name of the Web Site.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; siteId = getsiteid(friendlyWebsiteName);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (siteId != &lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; sitePath = &lt;SPAN style="COLOR: #006080"&gt;"IIS://localhost/W3SVC/"&lt;/SPAN&gt; + siteId + &lt;SPAN style="COLOR: #006080"&gt;"/IIsCertMapper"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt; (DirectoryEntry de = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; DirectoryEntry(sitePath))&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;                de.Invoke(&lt;SPAN style="COLOR: #006080"&gt;"CreateMapping"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;[] { certHash, user, password, clientCertMappingName, &lt;SPAN style="COLOR: #0000ff"&gt;true&lt;/SPAN&gt; });&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"Account Mapped: &amp;lt;B&amp;gt;"&lt;/SPAN&gt; + Request.ServerVariables[&lt;SPAN style="COLOR: #006080"&gt;"AUTH_USER"&lt;/SPAN&gt;] + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/B&amp;gt;&amp;lt;/BR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"Mapping Name: &amp;lt;B&amp;gt;"&lt;/SPAN&gt; + &lt;SPAN style="COLOR: #006080"&gt;"Mapping for "&lt;/SPAN&gt; + Request.ServerVariables[&lt;SPAN style="COLOR: #006080"&gt;"AUTH_USER"&lt;/SPAN&gt;] + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/B&amp;gt;&amp;lt;/BR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"Web Site: &amp;lt;B&amp;gt;"&lt;/SPAN&gt; + friendlyWebsiteName + &lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;/B&amp;gt;&amp;lt;/BR&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"&amp;lt;B&amp;gt;Web Site does not have a valid Site ID. Ensure we have the correct site name in the config file for this app.&amp;lt;/B&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;catch&lt;/SPAN&gt; (System.Runtime.InteropServices.COMException)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"A COM exception occurred while setting up the mapping."&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;catch&lt;/SPAN&gt; (SystemException)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"An error occurred while setting up the mapping."&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;catch&lt;/SPAN&gt; (Exception)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            Response.Write(&lt;SPAN style="COLOR: #006080"&gt;"An error occurred while setting up the mapping."&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;       &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;    }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; getsiteid(&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; websitename)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;    {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        DirectoryEntry root = &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; DirectoryEntry(&lt;SPAN style="COLOR: #006080"&gt;"IIS://localhost/W3SVC"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;try&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt; siteid = &lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;foreach&lt;/SPAN&gt; (DirectoryEntry de &lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt; root.Children)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;                &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (de.SchemaClassName == &lt;SPAN style="COLOR: #006080"&gt;"IIsWebServer"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;                {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;                    &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (websitename.ToUpper() == de.Properties[&lt;SPAN style="COLOR: #006080"&gt;"ServerComment"&lt;/SPAN&gt;].Value.ToString().ToUpper())&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;                        siteid = de.Name;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;                }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (siteid == &lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;) &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; siteid;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;catch&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;finally&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;            root.Close();&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;        }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;    }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ciao&lt;/P&gt;
&lt;P&gt;Nice weekend!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9544308" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/saurabh_singh/attachment/9544308.ashx" length="3384" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Client+Certificate/default.aspx">Client Certificate</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Code+Sample/default.aspx">Code Sample</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Tools/default.aspx">Tools</category></item><item><title>Unable to load DLL 'bcrypt.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)</title><link>http://blogs.msdn.com/saurabh_singh/archive/2009/04/08/unable-to-load-dll-bcrypt-dll-the-specified-module-could-not-be-found-exception-from-hresult-0x8007007e.aspx</link><pubDate>Thu, 09 Apr 2009 01:38:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9539093</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/9539093.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=9539093</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=9539093</wfw:comment><description>&lt;p&gt;I recently had the privilege to get access to a machine from a colleague of mine. It was a Windows server 2003 server and I had to test some ASP.Net application for one of my pet projects. I was focusing completely on the project at hand before I was completely taken off by a surprise, although not a pleasant one.&lt;/p&gt; &lt;p&gt;I found that my application was throwing the following exception, in fact forget my own application even a test Asp.Net 2.0 page having just a one word was failing. Also this happened for web resources hosted directly in IIS. If you run this app from within Cassini (ASP.Net Web server) you may not see this issue at all. This happened for both Website as well as WAP based applications hosted in IIS.&lt;/p&gt; &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;Server Error in '/' Application.
--------------------------------------------------------------------------------

Unable to load DLL 'bcrypt.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.DllNotFoundException: Unable to load DLL 'bcrypt.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[DllNotFoundException: Unable to load DLL 'bcrypt.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)]
   Microsoft.Win32.Win32Native.BCryptGetFipsAlgorithmMode(Boolean&amp;amp; pfEnabled) +0
   System.Security.Cryptography.Utils.get_FipsAlgorithmPolicy() +140
   System.Security.Cryptography.RijndaelManaged..ctor() +13
   System.Web.Configuration.MachineKeySection.ConfigureEncryptionObject() +232
   System.Web.Configuration.MachineKeySection.EnsureConfig() +156
   System.Web.Configuration.MachineKeySection.GetEncodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32&amp;amp; length) +37
   System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph) +166
   System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Serialize(Object state) +4
   System.Web.UI.Util.SerializeWithAssert(IStateFormatter formatter, Object stateGraph) +37
   System.Web.UI.HiddenFieldPageStatePersister.Save() +79
   System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state) +105
   System.Web.UI.Page.SaveAllState() +236
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1099

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 &lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This was quite perplexing as I couldn't find much information on this across the net. One incident I found talked about un-installation of&amp;nbsp; &lt;a href="http://support.microsoft.com/kb/931212" target="_blank"&gt;MS07-040&lt;/a&gt; security update. I was running on .Net framework 2.0 Sp2, Windows Server 2003 SP2. No luck with it. I had no clues about this dll which was missing as in the exception and why the heck it was looking for it in the first place.&lt;/p&gt;
&lt;p&gt;The interesting part here was that the call stack looked like having some encryption/decryption algorithm (RijndaelManaged) being used perhaps related to viewstate. I finally had to disable the attribute EnableViewStateMac="false" for the web page to make it work, but well that may not be an option all the time for everyone.&lt;/p&gt;
&lt;p&gt;If you face such a scenario just don't go ahead with reinstallation of .Net framework 2.0, it may not help you but only drain your precious time.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Analysis/Resolution&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;From this &lt;a href="http://support.microsoft.com/kb/911722" target="_blank"&gt;KB article&lt;/a&gt; this is what RijndaelManaged is all about.&lt;/p&gt;
&lt;p&gt;"ASP.NET 2.0 uses the RijndaelManaged implementation of the AES algorithm when it processes view state data. The ReindaelManaged implementation has not been certified by the National Institute of Standards and Technology (NIST) as compliant with the Federal Information Processing Standard (FIPS). Therefore, the AES algorithm is not part of the Windows Platform FIPS validated cryptographic algorithms."&lt;/p&gt;
&lt;p&gt;To work around this either set EnableViewStateMac to false or else add the following entry as mentioned in the kb under &lt;strong&gt;&amp;lt;system.web&amp;gt;&lt;/strong&gt; section for the web application.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;&amp;lt;machineKey validationKey="AutoGenerate,IsolateApps" decryptionKey="AutoGenerate,IsolateApps" validation="3DES" decryption="3DES"/&amp;gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;ASP.NET use the Triple Data Encryption Standard (3DES) algorithm to process view state data instead of the AES (Rijndael) algorithm. Remember this is comparatively weaker than Rijndael based encryption and hence your application will be comparatively insecure.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;*Note that the error message in the above article is not exactly the same as what I saw here for this post but the resolution remains the same :-).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Till next time..&lt;img alt="Beer mug" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/beer_mug.gif"&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9539093" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category></item><item><title>Asp.Net Request routing implementation fails with Null Reference exception</title><link>http://blogs.msdn.com/saurabh_singh/archive/2009/03/19/asp-net-request-routing-implementation-fails-with-null-reference-exception.aspx</link><pubDate>Thu, 19 Mar 2009 21:33:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9490832</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/9490832.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=9490832</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=9490832</wfw:comment><description>&lt;p&gt;I recently had the pleasure of working on the implementation of Asp.Net Request Routing feature that comes in bundled with .Net Framework 3.5 SP1. This is a cool stuff wherein care has been taken to ensure it can be used independently of MVC Framework. It can be used with Dynamic Data as well as implemented for any generic Asp.Net 2.0 application for Request routing functionality.&lt;/p&gt; &lt;p&gt;*Remember this is different from ASP.NET 2.0's URL Mapping.&lt;/p&gt; &lt;p&gt;The aim of this post is so obvious for many but I am writing this post because I couldn't get any pointers on this over the Internet, although I know I should have checked the end resolution in the very beginning; silly of me.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;We were getting the following exception when we we were trying to route a request. Exception was being thrown from within our custom class implementing IRouteHandler.&lt;/p&gt; &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;Server Error &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; &lt;span style="color: #006080"&gt;'/'&lt;/span&gt; Application. 
________________________________________
Object reference not set to an instance of an &lt;span style="color: #0000ff"&gt;object&lt;/span&gt;. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; more information about the error and &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; it originated &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an &lt;span style="color: #0000ff"&gt;object&lt;/span&gt;.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; the exception stack trace below. 

Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an &lt;span style="color: #0000ff"&gt;object&lt;/span&gt;.]
   System.Collections.Generic.Dictionary`2.GetEnumerator() +38
   Mycustomdll.Net.RouteHandler`1.GetHttpHandler(RequestContext requestContext) &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; C:\abcdedfgh\myprojectforfun\asdfsdf\Net\RouteHandler.cs:37
   System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +106
   System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +80
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp;amp; completedSynchronously) +75
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This application was failing for one of my customers in his environment. I was finally able to reproduce this problem locally on one of my machines as well. Found that ideally this should work fine if you have the latest build. 
&lt;p&gt;On debugging found it was failing at the section shown below in the custom Routehandler class while trying to iterate through the RouteValueDictionary collection even though there were items in the collection. It was failing with the null reference exception. &lt;pre class="code"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;RouteHandler&lt;/span&gt;:IRouteHandler
     {
        ...... 
        ......
       &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;IHttpHandler&lt;/span&gt; GetHttpHandler(RequestContext requestContext)
        {
             &lt;span style="color: rgb(0,0,255)"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(0,0,255)"&gt;var&lt;/span&gt; value &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; &lt;strong&gt;&lt;u&gt;requestContext.RouteData.Values&lt;/u&gt;&lt;/strong&gt;) &amp;lt;------------
             {
                 .....
             }
             .....
             .....
             &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(43,145,175)"&gt;Page&lt;/span&gt;)BuildManager.CreateInstanceFromVirtualPath(VirtualPath, &lt;span style="color: rgb(0,0,255)"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(43,145,175)"&gt;Page&lt;/span&gt;));
        }
     } &lt;/pre&gt;
&lt;p&gt;You may see this crash behavior if you are running with the build version of System.Web.routing as shown below. I assume this is from the ASP.Net 3.5 SP1 Beta release, not sure.&amp;nbsp; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/c394b3dfef01_9AF4/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="499" alt="image" src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/c394b3dfef01_9AF4/image_thumb.png" width="405" border="0"&gt;&lt;/a&gt; 
&lt;p&gt;In order to rectify this issue ensure you move to the latest build for System.Web.Routing.dll as well as for System.Web.Abstractions.dll. 
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/c394b3dfef01_9AF4/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="499" alt="image" src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/c394b3dfef01_9AF4/image_thumb_1.png" width="365" border="0"&gt;&lt;/a&gt; 
&lt;p&gt;Lesson: Never try to run Beta/CTP version etc. on the production environment. Ensure you have the latest bits deployed.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img alt="Coffee-cup" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/coffee.gif"&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9490832" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Troubleshooting/default.aspx">Troubleshooting</category></item><item><title>Programmatically managing Virtual Server using C#</title><link>http://blogs.msdn.com/saurabh_singh/archive/2008/10/25/programmatically-managing-virtual-server-using-c.aspx</link><pubDate>Sat, 25 Oct 2008 04:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9015523</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/9015523.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=9015523</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=9015523</wfw:comment><description>&lt;p&gt;Virtual Server 2005 (VS2005) is a well-known tool to manage Virtual Machines (VMs) on a host server. It is a great feature to manage virtualization for hardware/software. Most often one would use the VS2005 Web Admin&amp;nbsp; interface to manage VMs. But at times (like the way it recently happened for a customer of mine) one may want to programmatically control the VMs. This would most often sound a necessity if you would like to provide end users access to manage basic VM activities like turn on/off, save state etc. etc. without giving them access to everything as in through the VS2005 Web Admin site. &lt;/p&gt; &lt;p&gt;Here are some code snippets/sample web application/links in case you would like to try your hands on something like this.&lt;/p&gt; &lt;p&gt;Let me show you a typical screen-shot of how VS2005 Web Admin interface looks like.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_2.png"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_thumb.png" style="border-width: 0px;" alt="image" mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_thumb.png" border="0" height="388" width="640"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_8.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_8.png"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_thumb_3.png" style="border-width: 0px;" alt="image" mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_thumb_3.png" border="0" height="126" width="338"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;To programmatically manage the Virtual machines on a host server, you need to add a reference to a COM object for your .Net application which exposes various properties/methods.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_4.png"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_thumb_1.png" style="border-width: 0px;" alt="image" mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_thumb_1.png" border="0" height="380" width="463"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Visual Studio will add a COM Interop layer for this. You should see the following in your Visual Studio project:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_6.png"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_thumb_2.png" style="border-width: 0px;" alt="image" mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/a6ba50994cc4_4155/image_thumb_2.png" border="0" height="35" width="275"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Ensure we add a namespace as "using Microsoft.VirtualServer.Interop;" in the web/form page.&lt;/p&gt; &lt;p&gt;Here are code snippets (in C#) to:&lt;/p&gt; &lt;p&gt;a. &lt;b&gt;Turn On/Restore from a saved state &lt;/b&gt;for a Virtual machine on a local host machine.&lt;/p&gt; &lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;VMVirtualServerClass vs = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; VMVirtualServerClass();&lt;br&gt;&lt;br&gt;VMVirtualMachine vm = vs.FindVirtualMachine(VM_name);&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vm.State == VMVMState.vmVMState_TurnedOff || vm.State == VMVMState.vmVMState_Saved)&lt;br&gt;                {&lt;br&gt;                        VMTask vt = vm.Startup();&lt;br&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vt != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;br&gt;                            vt.WaitForCompletion(-1);&lt;br&gt;                }&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;b. &lt;b&gt;Turn Off &lt;/b&gt;a Virtual machine on a local host machine.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;VMVirtualServerClass vs = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; VMVirtualServerClass();&lt;br&gt;&lt;br&gt;VMVirtualMachine vm = vs.FindVirtualMachine(VM_name);&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vm.State == VMVMState.vmVMState_Running || vm.State == VMVMState.vmVMState_Paused)&lt;br&gt;                {&lt;br&gt;                        &lt;span style="color: rgb(0, 128, 0);"&gt;// Turn the power off on the Guest VM&lt;/span&gt;&lt;br&gt;                        Label1.Text = &lt;span style="color: rgb(0, 96, 128);"&gt;"Forcefully shutting down VM..."&lt;/span&gt;;&lt;br&gt;                        VMTask vt = vm.TurnOff();&lt;br&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vt != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;br&gt;                            vt.WaitForCompletion(-1);&lt;br&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;br&gt;                            Label1.Text = &lt;span style="color: rgb(0, 96, 128);"&gt;"Not ready for a turn off. Please wait and try again after a few seconds..."&lt;/span&gt;;&lt;br&gt;                 }&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;c. &lt;b&gt;Save state&lt;/b&gt; of a Virtual machine on a local host machine.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;VMVirtualServerClass vs = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; VMVirtualServerClass();&lt;br&gt;&lt;br&gt;VMVirtualMachine vm = vs.FindVirtualMachine(VM_name);&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vm.State == VMVMState.vmVMState_TurnedOff || vm.State == VMVMState.vmVMState_Saved)&lt;br&gt;                {&lt;br&gt;                        VMTask vt = vm.Startup();&lt;br&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vt != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;br&gt;                            vt.WaitForCompletion(-1);&lt;br&gt;                }&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;d. &lt;b&gt;Pause &lt;/b&gt;a Virtual machine on a local host machine.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;VMVirtualServerClass vs = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; VMVirtualServerClass();&lt;br&gt;&lt;br&gt;VMVirtualMachine vm = vs.FindVirtualMachine(VM_name);&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vm.State == VMVMState.vmVMState_TurnedOff || vm.State == VMVMState.vmVMState_Saved)&lt;br&gt;                {&lt;br&gt;                        VMTask vt = vm.Startup();&lt;br&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vt != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;br&gt;                            vt.WaitForCompletion(-1);&lt;br&gt;                }&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;e. &lt;b&gt;Resume&lt;/b&gt; a Virtual machine on a local host machine.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;VMVirtualServerClass vs = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; VMVirtualServerClass();&lt;br&gt;&lt;br&gt;VMVirtualMachine vm = vs.FindVirtualMachine(VM_name);&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vm.State == VMVMState.vmVMState_TurnedOff || vm.State == VMVMState.vmVMState_Saved)&lt;br&gt;                {&lt;br&gt;                        VMTask vt = vm.Startup();&lt;br&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vt != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;br&gt;                            vt.WaitForCompletion(-1);&lt;br&gt;                }&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;f. &lt;b&gt;Reset&lt;/b&gt; a Virtual machine on a local host machine.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;VMVirtualServerClass vs = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; VMVirtualServerClass();&lt;br&gt;&lt;br&gt;VMVirtualMachine vm = vs.FindVirtualMachine(VM_name);&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vm.State == VMVMState.vmVMState_TurnedOff || vm.State == VMVMState.vmVMState_Saved)&lt;br&gt;                {&lt;br&gt;                        VMTask vt = vm.Startup();&lt;br&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vt != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;br&gt;                            vt.WaitForCompletion(-1);&lt;br&gt;                }&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;g. &lt;b&gt;Shut down&lt;/b&gt; a virtual machine on a local host machine.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;VMVirtualServerClass vs = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; VMVirtualServerClass();&lt;br&gt;&lt;br&gt;VMVirtualMachine vm = vs.FindVirtualMachine(VM_name);&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vm.State == VMVMState.vmVMState_TurnedOff || vm.State == VMVMState.vmVMState_Saved)&lt;br&gt;                {&lt;br&gt;                        VMTask vt = vm.Startup();&lt;br&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vt != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;br&gt;                            vt.WaitForCompletion(-1);&lt;br&gt;                }&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;h. &lt;b&gt;Enumerate&lt;/b&gt; all the Virtual machines running on the local host machine.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;VMVirtualServerClass vs = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; VMVirtualServerClass();&lt;br&gt;&lt;br&gt;VMVirtualMachine vm = vs.FindVirtualMachine(VM_name);&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vm.State == VMVMState.vmVMState_TurnedOff || vm.State == VMVMState.vmVMState_Saved)&lt;br&gt;                {&lt;br&gt;                        VMTask vt = vm.Startup();&lt;br&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vt != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;br&gt;                            vt.WaitForCompletion(-1);&lt;br&gt;                }&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;i. Check various properties exposed through the COM API.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;VMVirtualServerClass vs = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; VMVirtualServerClass();&lt;br&gt;&lt;br&gt;VMVirtualMachine vm = vs.FindVirtualMachine(VM_name);&lt;br&gt;&lt;br&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; _VMName = vm.Name;&lt;br&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; _guestOS = String.Empty;&lt;br&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (vm.State == VMVMState.vmVMState_Running)&lt;br&gt;                    _guestOS = vm.GuestOS.OSName;&lt;br&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;br&gt;                    _guestOS = &lt;span style="color: rgb(0, 96, 128);"&gt;"OS: n/a"&lt;/span&gt;; &lt;br&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; _memory = vm.Memory.ToString();&lt;br&gt;                .......&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;j. At times if you want to manage VMs hosted on a remote machine and not on the local machine, here is what you need to do besides all the steps already mentioned above. &lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; VMVirtualServerClass connectToRemoteHost(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; remoteHost)&lt;br&gt;    {&lt;br&gt;        VMVirtualServerClass virtualServerCOM = &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;br&gt;        Type VMVirtualServerClassType = &lt;span style="color: rgb(0, 0, 255);"&gt;typeof&lt;/span&gt;(VMVirtualServerClass);&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;br&gt;        {&lt;br&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// create remote type from class identifier&lt;/span&gt;&lt;br&gt;            Type DCOMType = Type.GetTypeFromCLSID(VMVirtualServerClassType.GUID, remoteHost, &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;);&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; DCOMObject = Activator.CreateInstance(DCOMType);&lt;br&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// create local object from remote object&lt;/span&gt;&lt;br&gt;            virtualServerCOM = (VMVirtualServerClass)Marshal.CreateWrapperOfType(DCOMObject, VMVirtualServerClassType);&lt;br&gt;            TextBox1.Text = String.Empty;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; virtualServerCOM;&lt;br&gt;        }&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;br&gt;        {&lt;br&gt;            TextBox1.Text =&lt;span style="color: rgb(0, 96, 128);"&gt;"There was an error while connecting to the remote host. Make sure that we have the necessary permissions/settings to access the remote host"&lt;/span&gt;;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;br&gt;        }&lt;br&gt;    }&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Courtesy this MSDN &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163935.aspx" mce_href="http://msdn.microsoft.com/en-us/magazine/cc163935.aspx" target="_blank"&gt;magazine&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;I have not included error handling in the code snippets above. Please do so when you build the actual application. Also there are many other activities that can be performed besides the ones discussed above like setting up a VM from the beginning with various components like differencing, memory, network adapter etc., changing the disk configuration of an existing machine etc. etc.&lt;/p&gt;
&lt;p&gt;The more you explore the more you get to control through the code using the API mentioned above.&lt;/p&gt;
&lt;p&gt;Here are some useful links related to the topic.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163935.aspx" title="http://msdn.microsoft.com/en-us/magazine/cc163935.aspx" mce_href="http://msdn.microsoft.com/en-us/magazine/cc163935.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/cc163935.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://dotnet.sys-con.com/node/47338" title="http://dotnet.sys-con.com/node/47338" mce_href="http://dotnet.sys-con.com/node/47338"&gt;http://dotnet.sys-con.com/node/47338&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/david.wang/archive/2006/04/17/HOWTO-Perform-VHD-Maintenance-Automatically.aspx" title="http://blogs.msdn.com/david.wang/archive/2006/04/17/HOWTO-Perform-VHD-Maintenance-Automatically.aspx" mce_href="http://blogs.msdn.com/david.wang/archive/2006/04/17/HOWTO-Perform-VHD-Maintenance-Automatically.aspx"&gt;http://blogs.msdn.com/david.wang/archive/2006/04/17/HOWTO-Perform-VHD-Maintenance-Automatically.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blog.anildesai.net/?p=220" title="http://blog.anildesai.net/?p=220" mce_href="http://blog.anildesai.net/?p=220"&gt;http://blog.anildesai.net/?p=220&lt;/a&gt;, &lt;a href="http://blog.anildesai.net/?p=214" title="http://blog.anildesai.net/?p=214" mce_href="http://blog.anildesai.net/?p=214"&gt;http://blog.anildesai.net/?p=214&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Attached is a sample ASP.Net 2.0 web application to try the above commands if interested.&lt;/p&gt;
&lt;p&gt;Till next time our paths cross.&lt;/p&gt;
&lt;p&gt;Bye!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9015523" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/saurabh_singh/attachment/9015523.ashx" length="28538" type="application/octet-stream" /><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/.Net/default.aspx">.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Code+Sample/default.aspx">Code Sample</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Virtual+Server/default.aspx">Virtual Server</category></item><item><title>Change in IIS MMC setting may cause unwanted restarts of W3SVC</title><link>http://blogs.msdn.com/saurabh_singh/archive/2008/04/22/change-in-iis-mmc-setting-may-cause-unwanted-restarts-of-w3svc.aspx</link><pubDate>Tue, 22 Apr 2008 23:31:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8417183</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/8417183.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=8417183</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=8417183</wfw:comment><description>&lt;p&gt;Recently we have discovered an issue with IIS Manager wherein changing settings in a certain way may cause unexpected restart of World wide Web Publishing Service. And this may happen before you realize until you go back to the Application event log and find entries corresponding to the W3SVC restart event as shown below:&lt;/p&gt; &lt;p&gt;Event Type:&amp;nbsp;&amp;nbsp;&amp;nbsp; Information &lt;br&gt;Event Source:&amp;nbsp;&amp;nbsp;&amp;nbsp; ASP.NET 2.0.50727.0 &lt;br&gt;Event Category:&amp;nbsp;&amp;nbsp;&amp;nbsp; None &lt;br&gt;Event ID:&amp;nbsp;&amp;nbsp;&amp;nbsp; 1023 &lt;br&gt;Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4/22/2008 &lt;br&gt;Time:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6:35:20 AM &lt;br&gt;User:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N/A &lt;br&gt;Computer:&amp;nbsp;&amp;nbsp;&amp;nbsp; SAURABSI-SEC &lt;br&gt;Description: &lt;br&gt;&lt;font color="#ff0000"&gt;Restarting W3SVC&lt;/font&gt; &lt;/p&gt; &lt;p&gt;Event Type:&amp;nbsp;&amp;nbsp;&amp;nbsp; Information &lt;br&gt;Event Source:&amp;nbsp;&amp;nbsp;&amp;nbsp; ASP.NET 2.0.50727.0 &lt;br&gt;Event Category:&amp;nbsp;&amp;nbsp;&amp;nbsp; None &lt;br&gt;Event ID:&amp;nbsp;&amp;nbsp;&amp;nbsp; 1025 &lt;br&gt;Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4/22/2008 &lt;br&gt;Time:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6:35:25 AM &lt;br&gt;User:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N/A &lt;br&gt;Computer:&amp;nbsp;&amp;nbsp;&amp;nbsp; SAURABSI-SEC &lt;br&gt;Description: &lt;br&gt;&lt;font color="#ff0000"&gt;Finish restarting W3SVC&lt;/font&gt; &lt;/p&gt; &lt;p&gt;Also as part of the above symptom, you will see IIS mmc paused like in a hung state (you may see a transient hour glass). &lt;br&gt;So what are the steps you need to be cautious of especially in a production environment? &lt;br&gt;&lt;br&gt;First, a little background... &lt;br&gt;&lt;br&gt;If you intend to change the version of ASP.Net through IIS manager by going to the Web Site properties --&amp;gt; ASP.Net tab, you should be fully aware that W3SVC service will get restarted in order to reflect the change. Restarting of W3SVC will lead to all the application pools getting recycled along with it, hence leading to all your currently running web applications to spawn new worker processes for further requests. This is by design and if you want to circumvent the recycling of other application pools not corresponding to your website, you should have a way to control W3SVC restart after the version change. You can do so by following this excellent &lt;a href="http://blogs.msdn.com/jorman/archive/2006/04/14/asp-net-tab-forces-restart-of-w3svc.aspx" target="_blank"&gt;post&lt;/a&gt; by Jerry Orman. &lt;/p&gt; &lt;p&gt;So far so good. But I have something else to disclose too.&lt;/p&gt; &lt;p&gt;Let's say you go to the IIS manager, select a Web site, go to its properties and poke around with different settings. At some point you visit ASP.Net tab (even if you do not modify any settings like current ASP.Net version) and move out from there to some other tab. On this tab if you do any change(s), and you click on Apply and then OK (in the same order) bang!, your W3SVC service will restart and all your application pools will recycle subsequently as a result of it. &lt;br&gt;&lt;br&gt;Here are some quick steps to reproduce the problem, follow it to believe it.&lt;/p&gt; &lt;p&gt;1) Open IIS manager (Start -&amp;gt; Run -&amp;gt; inetmgr.exe) &lt;br&gt;2) Select any website --&amp;gt; right click and select properties &lt;br&gt;3) Click on ASP.NET TAB - do not change or modify anything - just click on the TAB.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="465" alt="image" src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/8807287c1dba_10CF0/image_8.png" width="471" border="0"&gt; &lt;br&gt;&lt;br&gt;4) Now click on any other TAB and change some values (for example: go to website tab and change port to say 8080 from 80) &lt;br&gt;5) Hit apply &lt;br&gt;6) Hit OK &lt;br&gt;7) This will restart W3SVC and you will see following event in application event logs.&lt;/p&gt; &lt;p&gt;In the above steps the key points are basically to visit the ASP.NET TAB and then click on Apply and then OK to reproduce the issue. &lt;/p&gt; &lt;p&gt;Why is this behavior? &lt;br&gt;=================== &lt;br&gt;The reason this behavior occurs is in the code where we make a check to see if ASP.NET runtime version is changed and if yes we need to fire W3SVC restart. We are comparing the selected version of ASP.NET TAB with what has been changed incorrectly. There is an additional code in place that checks for the QFE versions of the ASP.NET framework installed, but in the IIS manager UI, we only give an option to either select 1.x.xxxx or 2.0.xxxxx. We really don’t care about the QFE versions installed after that. But the code that gets executed on OK or APPLY does. For the 1st execution (i.e. click on APPLY) it’s correctly able to remove the QFE information from the version string it retrieved (i.e. 2.0.xxxxx, instead of 2.0.xxxxx.QFE), the check is successful noting that nothing is changed in ASP.NET TAB, and hence no restart of W3SVC is required. But now when we go ahead with 2nd execution (i.e. click on OK) the same code executes again and this time the version information string is truncated further to RTM (i.e. to 2.0 from 2.0.xxxxx) and thus the check fails (ASP.Net version is changed from 2.0.xxxxx to 2.0), which incorrectly indicates that ASP.NET runtime version has been changed and thus calls a restart of W3SVC. &lt;/p&gt; &lt;p&gt;In short, you could click anywhere in UI all day long, but for you to reproduce this issue, you need to &lt;br&gt;1) Go to ASP.NET UI once. &lt;br&gt;2) Click APPLY and OK (both in that order). If you only click OK then the code gets executed only once and hence correctly and would not restart the w3svc. &lt;/p&gt; &lt;p&gt;Latest update on this:&lt;/p&gt; &lt;p&gt;We have informed the Product group about this issue. A Knowledge base article is in work. &lt;br&gt;&lt;br&gt;Laterz! &lt;br&gt;Saurabh&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/saurabh_singh" target="_blank"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8417183" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/service+startup/default.aspx">service startup</category></item><item><title>Unable to correctly display Chinese (Unicode) characters in Excel when opened through ASP.Net page</title><link>http://blogs.msdn.com/saurabh_singh/archive/2008/02/27/unable-to-correctly-display-chinese-unicode-characters-in-excel-when-opened-through-asp-net-page.aspx</link><pubDate>Wed, 27 Feb 2008 04:12:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7912250</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/7912250.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=7912250</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=7912250</wfw:comment><description>&lt;p&gt;Recently I was working on an issue wherein one of our customers was trying to stream data from their web application in CSV format for it to be recognizable and opened through Excel on the client's end. Basically they were setting content-type and content-disposition to open the file outside the browser and open it in MS-Excel. Everything would have worked had they not used Chinese characters as data in this case.&lt;/p&gt; &lt;p&gt;Something like this: &lt;/p&gt; &lt;p&gt;Page.Response.Clear()&lt;br&gt;Page.Response.ContentType = "application/vnd.ms-excel"&lt;br&gt;Page.Response.ContentEncoding = System.Text.Encoding.UTF8&lt;br&gt;Page.Response.AddHeader("Content-Disposition", "attachment; filename=ExportData.xls")&lt;/p&gt; &lt;p&gt;And later in the code they were reading the column headers and column row in CSV format into a string which will get flushed as a response output.&lt;/p&gt; &lt;p&gt;Something like this: &lt;/p&gt; &lt;p&gt;'Output Column Headers as&amp;nbsp; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columnHeaders = "HEADER1" + Chr(9) + "HEADER2"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columnHeaders = columnHeaders &amp;amp; Chr(13) &amp;amp; Chr(10) &lt;p&gt;[Here, Chr(9), Chr(10) and Chr(13) correspond to Tab, Linefeed and Carriage Return characters in ASCII respectively to adhere to CSV format]&lt;/p&gt; &lt;p&gt;Page.Response.Write(columnHeaders)&lt;br&gt;Page.Response.Write(Chr(10)) &lt;p&gt;and &lt;p&gt;'Output Column Row as&lt;br&gt;columnRow = "" &lt;p&gt;After populating the columns in various strings we do this to adhere to CSV format: &lt;p&gt;columnRow = coulmn1 + Chr(9) + column2 &lt;p&gt;columnRow = columnRow &amp;amp; Chr(13) &amp;amp; Chr(10) &lt;p&gt;............... &lt;p&gt;Page.Response.Write(columnRow)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Finally display the data &lt;p&gt;Now if you see above this should work if we try to open the file using Excel. Although if we are sending the data in UTF-8 encoding (let's say for Chinese characters), Excel doesn't recognize it correctly and opens it in ASCII. In normal scenarios the above functionality will not cause issues but if we are using any Unicode characters like Chinese the data will be wrongly displayed in Excel. You may see "???????" etc. Although it may display perfectly fine in the webpage control , let's say in a datagrid. &lt;p&gt;The resolution to such an issue is to switch from UTF-8 to Unicode and add Unicode byte leader &lt;br&gt;to the start of the file. Excel will recognize the byte-leader as an indication of Unicode data coming in, and correctly read the file as Unicode. This way Unicode characters like Chinese can be preserved when opened through Excel. &lt;p&gt;Here is something you can try: &lt;blockquote&gt; &lt;p&gt;Dim rgByteLeader(1) As Byte&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rgByteLeader(0) = &amp;amp;HFF&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rgByteLeader(1) = &amp;amp;HFE&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Response.Clear()&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Response.ContentType = "application/vnd.ms-excel"&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Response.ContentEncoding = System.Text.Encoding.Unicode&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Response.AddHeader("Content-Disposition", "attachment; filename=ExportData.xls")&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;' Write out the Unicode header FFFE so that Excel recognizes the file as Unicode()&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Response.BinaryWrite(rgByteLeader)&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;'Output Column Headers as before &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columnHeaders = "HEADER1" + Chr(9) + "HEADER2"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columnHeaders = columnHeaders &amp;amp; Chr(13) &amp;amp; Chr(10)&lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Response.Write(columnHeaders)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Response.Write(Chr(10))&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;'Output Column Rows as before&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columnRow = ""&lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .............&lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columnRow = coulmn1 + Chr(9) + column2 &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columnRow = columnRow &amp;amp; Chr(13) &amp;amp; Chr(10)  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Response.Write(columnRow)&lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .....&lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Page.Response.End()&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I am no Globalization/MS-Excel expert but I had a tough time researching on this issue so thought of sharing it with others. Hope this helps!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7912250" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/MS+Office/default.aspx">MS Office</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Globalization/default.aspx">Globalization</category></item><item><title>How to achieve a feature similar to single logon for multiple web applications using Basic authentication</title><link>http://blogs.msdn.com/saurabh_singh/archive/2007/08/09/single-logon-for-multiple-web-applications-using-basic-authentication.aspx</link><pubDate>Fri, 10 Aug 2007 01:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4314728</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/4314728.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=4314728</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=4314728</wfw:comment><description>&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is something which I recently figured out. This may be very simple to&amp;nbsp;many but thought&amp;nbsp;of sharing it for a wider audience.&amp;nbsp; 
&lt;P&gt;Let's say you have two ASP.Net web applications running on two different servers.&lt;BR&gt;Now, assuming you have a constraint wherein you cannot use Windows integrated authentication (in cases where in you have some JSP application running on Websphere and another Asp.Net app on IIS server or any multi-platform scenarios), and you want to access the 2nd web app internally from the 1st web app for authenticated users. Now since you cannot use windows integrated authentication (e.g. Websphere doesn't support windows integrated authentication) the only option is to use Basic authentication which is supported across multiple platforms. 
&lt;P&gt;So here Windows integrated and anonymous authentication are out of picture and you are left with Basic authentication. Now if you want to access the 2nd Web app internally from the 1st web app and since both are configured for Basic authentication what will you do. IIS prompts for basic authentication and since you are trying to access it internally from the 1st web app you may get into issues wherein IIS will throw 401 Unauthorized error. 
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1st Web app&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 2nd Web app&amp;nbsp;&lt;BR&gt;(Basic Authentication)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Basic Authentication) 
&lt;P&gt;Had Windows integrated authentication been supported we could have gone ahead with Kerberos but now that is out of picture. 
&lt;P&gt;This is what I figured out. If a user is authenticated using basic authentication, an Authorization header is passed (after user enters the credentials and is authenticated) to the server as part of the request header. Now this header will remain the same for a combination of username and password. Web server recognizes the future requests for the same user using the same header. 
&lt;P&gt;Now if you try to call the 2nd web app URL through the 1st web app using &lt;EM&gt;httpwebrequest&lt;/EM&gt; you will get 401 unauthorized. This is because the web request from the 1st web app does not send the Basic authentication token to the destination by default. It sends a new request to the 2nd web app and since 2nd web app is configured for basic authentication only and no anonymous authentication it will fail with 401. 
&lt;P&gt;To avoid getting into such issues you can modify your code in the 1st web app such that it also appends the Authorization header (which it gets during the first basic authentication done by the 1st server) along with the new http request to the 2nd web app (now all this assuming the user is allowed to access both the websites on both the servers). 
&lt;P&gt;Here is code snippet on the 1st web app which calls the 2nd web app internally. 
&lt;P&gt;Default.aspx&lt;BR&gt;==============&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_1.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_1.png" atomicselection="true"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=328 alt=image src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_thumb_1.png" width=909 border=0 mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Default.aspx.cs&lt;BR&gt;===============&lt;BR&gt;&amp;nbsp;&lt;A href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_3.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_3.png" atomicselection="true"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=250 alt=image src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_thumb_3.png" width=818 border=0 mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Assuming web app2 being&amp;nbsp;&lt;A href="http://shrek:8080/default.aspx" mce_href="http://shrek:8080/default.aspx"&gt;http://shrek:8080/default.aspx&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Here is the error thrown on the browser: 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image.png" atomicselection="true"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=437 alt=image src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_thumb.png" width=876 border=0 mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_thumb.png"&gt;&lt;/A&gt; 
&lt;P&gt;Now try adding the following lines and browse to the page in web app1. You should be able to access the web app2 without any issues. 
&lt;P&gt;Default.aspx.cs&lt;BR&gt;=============== 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_4.png" atomicselection="true"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=399 alt=image src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_thumb_4.png" width=813 border=0 mce_src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/691103fa9d55_221D/image_thumb_4.png"&gt;&lt;/A&gt; 
&lt;P&gt;If you notice we are resending the authorization header that we got during the 1st web app authentication process. The same authorization header when accessing the 2nd web app nullifies the requirement for a new authentication handshake between IIS and the its client request. If we did not pass the authorization header to the 2nd web request IIS has to renegotiate a new authentication process with its client in order to get the necessary credentials for allowing access to its contents. Thereby throwing error 401 in our case since we are calling the 2nd web app internally in the code. The above scenario can work for N number of websites which can easily be greater than 2. 
&lt;P&gt;Do remember to add resp.close() and reader.close() in the above code section at the end. 
&lt;P&gt;If IIS is&amp;nbsp;configured for basic authentication only it will look for Basic Authorization header before serving the request. 
&lt;P&gt;Also remember if you use just a response.redirect from 1st web app to 2nd web app it will work just fine but you will be prompted twice for basic authentication. This is because you get&amp;nbsp;prompted for credentials the first time when you access the 1st web app and then again&amp;nbsp;when a new request is sent for the 2nd web app&amp;nbsp;through response.redirect it doesn't have the authorization header by default (Remember response.redirect cause a new request to be sent to the server from the&amp;nbsp;client's end). So IIS again prompts you for credentials. 
&lt;P&gt;If it doesn't find an authorization header it will send a 401 response back asking the client to resend the request with a valid authorization header. Here above we are adding an authorization header along with the request in the first place so that IIS need not send 401 response. 
&lt;P&gt;***Basic authentication sends credentials in clear text and is base64 encoded. So it can be easily decoded by a &lt;A href="http://www.webopedia.com/TERM/S/sniffer.html" mce_href="http://www.webopedia.com/TERM/S/sniffer.html"&gt;sniffer&lt;/A&gt;. So its recommended to use SSL with basic authentication.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4314728" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/IIS/default.aspx">IIS</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Basic+Authentication/default.aspx">Basic Authentication</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Authentication/default.aspx">Authentication</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Code+Sample/default.aspx">Code Sample</category></item><item><title>Accessing Request.CurrentExecutionFilePath property in Response.Redirect Vs Server.Transfer methods</title><link>http://blogs.msdn.com/saurabh_singh/archive/2007/04/20/accessing-request-currentexecutionfilepath-property-in-response-redirect-vs-server-transfer-methods.aspx</link><pubDate>Fri, 20 Apr 2007 12:23:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2204806</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/2204806.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=2204806</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=2204806</wfw:comment><description>&lt;p&gt;Ok,&amp;nbsp;I understand you might feel lethargic while&amp;nbsp;viewing this blog of mine thinking, here&amp;nbsp;again the same old crap about server.transfer and response.redirect.&lt;/p&gt; &lt;p&gt;Don't know how many links you would already have&amp;nbsp;found if you did a Live or Google on the net on the above commands. I at least found two dozens of them.&lt;/p&gt; &lt;p&gt;So here I am not going to talk not about what they mean but a little weird scenario when it comes to using Request properties like Request.CurrentExecutionFilePath.&lt;/p&gt; &lt;p&gt;We had a customer who had written his own custom HTTP Module which intercepts request and response for Asp.Net pages.&lt;/p&gt; &lt;p&gt;Now, in his HTTP Module, he was trying to&amp;nbsp;access the Request.CurrentExecutionFilePath property. Simple!&lt;/p&gt; &lt;p&gt;The problem arises when you use the above mechanisms, especially using Server.Transfer.&lt;/p&gt; &lt;p&gt;We know that in Response.Redirect the request flows between client and the server until we get the right path for the requested page.&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Client&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Server&lt;/p&gt;&lt;/blockquote&gt; &lt;blockquote&gt; &lt;p&gt;GET /redirecttransfer/default.aspx HTTP/1.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HTTP/1.1 302 Found &lt;p align="center"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Location: /redirecttransfer/Default2.aspx&lt;/p&gt;&lt;/blockquote&gt; &lt;p align="left"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GET /redirecttransfer/Default2.aspx HTTP/1.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HTTP/1.1 302 Found&lt;/p&gt; &lt;blockquote&gt; &lt;p align="left"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Location: /redirecttransfer/default3.aspx&lt;/p&gt; &lt;p align="left"&gt;GET /redirecttransfer/default3.aspx HTTP/1.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HTTP/1.1 200 OK&lt;/p&gt; &lt;p align="left"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;So here we have a complete round trip between the server and the client. The Request will have all the information about the requested page, accordingly we should get the right value in Request.CurrentExecutionFilePath (which should be Default3.aspx here). But what happens if you try to read the same property when using Server.Transfer instead of Response.Redirect?&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Let's say the request flow is: &lt;strong&gt;Default.aspx&lt;/strong&gt;&amp;nbsp; &amp;gt;&amp;gt;--Server.Transfer--&amp;gt; &lt;strong&gt;Default2.aspx&lt;/strong&gt; &amp;gt;&amp;gt;--Server.Transfer--&amp;gt; &lt;strong&gt;Default3.aspx&lt;/strong&gt; &lt;/p&gt; &lt;p&gt;Now in the HTTPModule under &lt;em&gt;Application_EndRequest &lt;/em&gt;method, if we try to display the Request.CurrentExecutionFilePath property, what should we see?&lt;/p&gt; &lt;p&gt;Guess....should it be Default.aspx, or Default2.aspx or Default3.aspx or something else altogether.&lt;/p&gt; &lt;p&gt;Check it yourself, I am adding a sample HTTPModule here:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;public class HelloWorldModule : IHttpModule&lt;br&gt;{&lt;br&gt;public HelloWorldModule()&lt;br&gt;{&lt;br&gt;}  &lt;p&gt;public String ModuleName&lt;br&gt;{&lt;br&gt;get { return "HelloWorldModule" }&lt;br&gt;}  &lt;p&gt;// In the Init function, register for HttpApplication &lt;br&gt;// events by adding your handlers.&lt;br&gt;public void Init(HttpApplication application)&lt;br&gt;{&lt;br&gt;application.BeginRequest += new EventHandler(this.Application_BeginRequest);&lt;br&gt;application.EndRequest += new EventHandler(this.Application_EndRequest);&lt;br&gt;}  &lt;p&gt;private void Application_BeginRequest(Object source, EventArgs e)&lt;br&gt;{&lt;br&gt;// Create HttpApplication and HttpContext objects to access&lt;br&gt;// request and response properties.&lt;br&gt;HttpApplication application = (HttpApplication)source;&lt;br&gt;HttpContext context = application.Context;&lt;br&gt;context.Response.Write("&amp;lt;h1&amp;gt;&amp;lt;font color=red&amp;gt;HelloWorldModule: Beginning of Request&amp;lt;/font&amp;gt;&amp;lt;/h1&amp;gt;&amp;lt;hr&amp;gt;");&lt;br&gt;}  &lt;p&gt;&lt;strong&gt;private void Application_EndRequest(Object source, EventArgs e)&lt;br&gt;{&lt;br&gt;HttpApplication application = (HttpApplication)source;&lt;br&gt;HttpContext context = application.Context;&lt;br&gt;context.Response.Write(&lt;font color="#ff0000"&gt;context.Request.CurrentExecutionFilePath&lt;/font&gt;+"&amp;lt;/br&amp;gt;&amp;lt;hr&amp;gt;&amp;lt;h1&amp;gt;&amp;lt;font color=red&amp;gt;HelloWorldModule: End of Request&amp;lt;/font&amp;gt;&amp;lt;/h1&amp;gt;");&lt;br&gt;} &lt;/strong&gt; &lt;p&gt;public void Dispose()&lt;br&gt;{&lt;br&gt;}&lt;br&gt;} &lt;p&gt;&amp;nbsp; &lt;p&gt;Also let's say you have default.aspx, default2.aspx and default3.aspx as shown above in the flow diagram. We do a server.transfer from default.aspx to default2.aspx, which in turn does a server.transfer to default3.aspx page. &lt;p&gt;Here are the codes: &lt;p&gt;Default.aspx &lt;p&gt;public partial class _Default : System.Web.UI.Page &lt;br&gt;{&lt;br&gt;protected void Page_Load(object sender, EventArgs e)&lt;br&gt;{&lt;br&gt;Response.Write(Request.CurrentExecutionFilePath);&lt;br&gt;&lt;strong&gt;Server.Transfer("Default2.aspx");&lt;/strong&gt;&lt;br&gt;}&lt;br&gt;} &lt;p&gt;&amp;nbsp; &lt;p&gt;Default2.aspx &lt;p&gt;public partial class Default2 : System.Web.UI.Page&lt;br&gt;{&lt;br&gt;protected void Page_Load(object sender, EventArgs e)&lt;br&gt;{&lt;br&gt;Response.Write(Request.CurrentExecutionFilePath);&lt;br&gt;&lt;strong&gt;Server.Transfer("default3.aspx");&lt;/strong&gt;&lt;br&gt;}&lt;br&gt;} &lt;p&gt;&amp;nbsp; &lt;p&gt;Default3.aspx &lt;p&gt;public partial class Default3 : System.Web.UI.Page&lt;br&gt;{&lt;br&gt;protected void Page_Load(object sender, EventArgs e)&lt;br&gt;{&lt;br&gt;&lt;strong&gt;Response.Write(Request.CurrentExecutionFilePath);&lt;/strong&gt;&lt;br&gt; &lt;p&gt;}&lt;br&gt;} &lt;p&gt;You will notice that when you try to access the default.aspx page it does the server.redirect to default2.aspx which in turn again redirects to default3.aspx page and then finally the httpmodule displays the following: &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Response.RedirectVsServer.Transfer_B5A3/image%7B0%7D%5B9%5D.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="341" src="http://blogs.msdn.com/blogfiles/saurabh_singh/WindowsLiveWriter/Response.RedirectVsServer.Transfer_B5A3/image%7B0%7D_thumb%5B5%5D.png" width="836" border="0"&gt;&lt;/a&gt;  &lt;p&gt;&amp;nbsp; &lt;p&gt;Now if you notice&amp;nbsp;the HTTP Module displays /Default.aspx and not /default2.aspx or /default3.aspx. &lt;p&gt;What can be the reason behind it. If you notice the Request.FilePath&amp;nbsp;associated with Httpmodule is still /Default.aspx and not any of /default2.aspx or /default3.aspx page. The reason being that&amp;nbsp;in addition to being faster than redirection, server.transfer preserves all of the ASP built-in objects from the original request, including form values from an HTTP post. The moment we have server.transfer in our code the currently executing request will stop and will forward the request to the new page.  &lt;p&gt;The new request&amp;nbsp;also gets the original response stream&amp;nbsp;further ahead for processing. Hence the property Request.CurrentExecutionFilePath will be same as the executing page when accessed in one of the&amp;nbsp;above page class methods, but will be equal to the original request property if accessed in an HTTP Module. You can also consider it logically, why should there be a value for Request.CurrentExecutionFilePath in an HttpModule, it is called before or after the pages have been processed. So ideally it is not in context of any specific page. Hence it will show you the original page based on the assumption that the request was sent for the same page.  &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2204806" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category></item><item><title>Getting little deeper: How ASP.Net Forms based authentication flows...</title><link>http://blogs.msdn.com/saurabh_singh/archive/2007/04/19/getting-little-deeper-how-asp-net-forms-based-authentication-flows.aspx</link><pubDate>Thu, 19 Apr 2007 13:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2190044</guid><dc:creator>Saurabh Singh</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/saurabh_singh/comments/2190044.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh_singh/commentrss.aspx?PostID=2190044</wfw:commentRss><wfw:comment>http://blogs.msdn.com/saurabh_singh/rsscomments.aspx?PostID=2190044</wfw:comment><description>&lt;p&gt;I have been recently supporting Asp.Net apart from IIS&amp;nbsp;in the role of a&amp;nbsp;Microsoft GTSC Developer Support Engineer.&lt;/p&gt; &lt;p&gt;I&amp;nbsp;had been a programmer earlier, but had more expertise on C, C++ and other unmanaged non-web stuffs. I am new to Web technology as per the programming background is concerned. I started working on specific topics which we regularly encounter in our daily support calls, and found Forms based authentication to be one of the most interesting and&amp;nbsp;challenging topics to troubleshoot.&lt;/p&gt; &lt;p&gt;Here i take a moment to dig deep in explaining the forms authentication. The below analysis helped me in a big way to understand how the HTTP traffice flows and what are the headers we need to concentrate upon.&lt;/p&gt; &lt;p&gt;I will show&amp;nbsp;a series of Web request/response flows when a user tries to access a website which is configured for Forms based authentication. &lt;/p&gt; &lt;p&gt;Let's say, a user requests for accessing a protected web page on a site.&lt;/p&gt; &lt;p&gt;So accordingly he should be redirected to a login page where he needs to enter the credentials and once validated against a user data store, he should be taken to the requested page.&lt;/p&gt; &lt;p&gt;For our example&amp;nbsp;I have written a very generic&amp;nbsp;code as shown below:&lt;/p&gt; &lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Default.aspx&lt;/em&gt; page, which&amp;nbsp;checks whether user is authenticated or not. If yes, then it displays&amp;nbsp;webpage content. If user is not authenticated he will be redirected to the login page. You can copy paste and try it for yourself.&lt;/p&gt; &lt;p&gt;&lt;u&gt;Default.aspx&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&amp;lt;%@Page Language="VB"&amp;nbsp;%&amp;gt;&lt;br&gt;&amp;lt;%@Import Namespace="System.Web.Security" %&amp;gt; &lt;/p&gt; &lt;p&gt;&amp;lt;script language="vb" runat="server"&amp;gt;  &lt;p&gt;Sub SignOut(objSender As Object, objArgs As EventArgs)&lt;br&gt;'delete the users auth cookie and sign out&lt;br&gt;FormsAuthentication.SignOut()&lt;br&gt;'redirect the user to their referring page&lt;br&gt;Response.Redirect(Request.UrlReferrer.ToString())&lt;br&gt;End Sub  &lt;p&gt;Sub Page_Load()&lt;br&gt;'verify authentication&lt;br&gt;If User.Identity.IsAuthenticated Then&lt;br&gt;'display Credential information&lt;br&gt;displayCredentials.InnerHtml = "Current User : &amp;lt;b&amp;gt;" &amp;amp; User.Identity.Name &amp;amp; "&amp;lt;/b&amp;gt;" &amp;amp; _&lt;br&gt;"&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Authentication Used : &amp;lt;b&amp;gt;" &amp;amp; User.Identity.AuthenticationType &amp;amp; "&amp;lt;/b&amp;gt;"&lt;br&gt;session("Name") = User.Identity.Name&lt;br&gt;Else&lt;br&gt;'Display Error Message&lt;br&gt;displayCredentials.InnerHtml = "Sorry, you have not been authenticated."&lt;br&gt;End If&lt;br&gt;End Sub  &lt;p&gt;&amp;lt;/script&amp;gt;  &lt;p&gt;&amp;lt;html&amp;gt;&lt;br&gt;&amp;lt;head&amp;gt;&lt;br&gt;&amp;lt;title&amp;gt;Forms Authentication&amp;lt;/title&amp;gt;&lt;br&gt;&amp;lt;/head&amp;gt;&lt;br&gt;&amp;lt;body bgcolor="#FFFFFF" text="#000000"&amp;gt;&lt;br&gt;&amp;lt;span class="Header"&amp;gt;Forms Based Authentication using standard method&amp;lt;/span&amp;gt;&lt;br&gt;&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;div id="displayCredentials" runat="server" /&amp;gt;&lt;br&gt;&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;form runat="server" method="POST"&amp;gt;&lt;br&gt;&amp;lt;asp:TextBox id="TextBox1" runat="server" /&amp;gt;&lt;br&gt;&amp;lt;asp:Button id="cmdSignOut" text="Sign Out" runat="server" onClick="SignOut" /&amp;gt;&lt;br&gt;&amp;lt;asp:Button id="Button1" runat="server" text="Submit"/&amp;gt;&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;asp:TextBox id="TextBox2" runat="server" /&amp;gt;&lt;br&gt;&amp;lt;/form&amp;gt;&lt;br&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&amp;lt;/html&amp;gt;  &lt;p&gt;&lt;u&gt;Login.aspx&lt;/u&gt;  &lt;p&gt;&amp;lt;%@Page Language="VB" %&amp;gt;&lt;br&gt;&amp;lt;%@Import Namespace="System.Web.Security" %&amp;gt;  &lt;p&gt;&amp;lt;script language="VB" runat="server"&amp;gt;  &lt;p&gt;Sub ProcessLogin(objSender As Object, objArgs As EventArgs)  &lt;p&gt;If FormsAuthentication.Authenticate(txtUser.Text, txtPassword.Text) Then&lt;br&gt;FormsAuthentication.RedirectFromLoginPage(txtUser.Text, chkPersistLogin.Checked)&lt;br&gt;Else&lt;br&gt;ErrorMessage.InnerHtml = "&amp;lt;b&amp;gt;Something went wrong...&amp;lt;/b&amp;gt; please re-enter your credentials..."&lt;br&gt;End If  &lt;p&gt;End Sub  &lt;p&gt;&amp;lt;/script&amp;gt;  &lt;p&gt;&amp;lt;html&amp;gt;&lt;br&gt;&amp;lt;head&amp;gt;&lt;br&gt;&amp;lt;title&amp;gt;Standard Forms Authentication Login Form&amp;lt;/title&amp;gt;&lt;br&gt;&amp;lt;/head&amp;gt;  &lt;p&gt;&amp;lt;body bgcolor="#FFFFFF" text="#000000"&amp;gt;&lt;br&gt;&amp;lt;form runat="server"&amp;gt;&lt;br&gt;&amp;lt;table width="400" border="0" cellspacing="0" cellpadding="0"&amp;gt;&lt;br&gt;&amp;lt;tr&amp;gt;&lt;br&gt;&amp;lt;td width="80"&amp;gt;Username : &amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;td width="10"&amp;gt; &amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;td&amp;gt;&amp;lt;asp:TextBox Id="txtUser" width="150" runat="server"/&amp;gt;&amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;/tr&amp;gt;&lt;br&gt;&amp;lt;tr&amp;gt;&lt;br&gt;&amp;lt;td&amp;gt;Password : &amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;td width="10"&amp;gt; &amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;td&amp;gt;&amp;lt;asp:TextBox Id="txtPassword" width="150" TextMode="Password" runat="server"/&amp;gt;&amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;/tr&amp;gt;&lt;br&gt;&amp;lt;tr&amp;gt;&lt;br&gt;&amp;lt;tr&amp;gt;&lt;br&gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;td width="10"&amp;gt; &amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;td&amp;gt;&amp;lt;asp:CheckBox id="chkPersistLogin" runat="server" /&amp;gt;Remember my credentials&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;/tr&amp;gt;&lt;br&gt;&amp;lt;tr&amp;gt;&lt;br&gt;&amp;lt;td&amp;gt; &amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;td width="10"&amp;gt; &amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;td&amp;gt;&amp;lt;asp:Button Id="cmdLogin" OnClick="ProcessLogin" Text="Login" runat="server" /&amp;gt;&amp;lt;/td&amp;gt;&lt;br&gt;&amp;lt;/tr&amp;gt;&lt;br&gt;&amp;lt;/table&amp;gt;&lt;br&gt;&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;div id="ErrorMessage" runat="server" /&amp;gt;&lt;br&gt;&amp;lt;/form&amp;gt;&lt;br&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&amp;lt;/html&amp;gt;  &lt;p&gt;For demonstration purpose I have added users to the web.config files instead of using any other store like a SQL server or Active Directory store for storing user's credentials.  &lt;p&gt;Here is the &lt;u&gt;web.config&lt;/u&gt; file section of our interest:  &lt;p&gt;&amp;lt;configuration&amp;gt;&lt;br&gt;&amp;lt;system.web&amp;gt;&lt;br&gt;&amp;lt;customErrors mode="Off"/&amp;gt; &lt;/p&gt; &lt;p&gt;&amp;lt;authentication mode="&lt;strong&gt;Forms&lt;/strong&gt;"&amp;gt;&lt;br&gt;&amp;lt;forms name="FormsAuthCookie" path="/" loginUrl="login.aspx" protection="All" &lt;strong&gt;timeout="1" slidingExpiration="false"&lt;/strong&gt;&amp;gt;&lt;br&gt;&amp;lt;credentials passwordFormat="Clear"&amp;gt;&lt;br&gt;&lt;strong&gt;&amp;lt;user name="john" password="test1" /&amp;gt;&lt;br&gt;&amp;lt;user name="Randy" password="test2" /&amp;gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;....&lt;br&gt;&lt;/strong&gt;&amp;lt;/credentials&amp;gt;&lt;br&gt;&amp;lt;/forms&amp;gt;&lt;br&gt;&amp;lt;/authentication&amp;gt; &lt;/p&gt; &lt;p&gt;&amp;lt;authorization&amp;gt;&lt;br&gt;&lt;strong&gt;&amp;lt;deny users="?" /&amp;gt;&lt;/strong&gt;&lt;br&gt;&amp;lt;/authorization&amp;gt; &lt;/p&gt; &lt;p&gt;&amp;lt;sessionState &lt;br&gt;mode="InProc" &lt;br&gt;stateConnectionString="tcpip=127.0.0.1:42424" &lt;br&gt;stateNetworkTimeout="10" &lt;br&gt;sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI" &lt;br&gt;sqlCommandTimeout="30" &lt;br&gt;cookieless="UseCookies" &lt;br&gt;cookieName="AppSessionCookie" &lt;br&gt;&lt;strong&gt;timeout="2"&lt;/strong&gt;&amp;gt; &lt;br&gt;&amp;lt;/sessionState&amp;gt;  &lt;p&gt;&amp;lt;/system.web&amp;gt;&lt;br&gt;&amp;lt;/configuration&amp;gt;  &lt;p&gt;Here if you notice,&amp;nbsp;I have set the SlidingExpiration to False, which mean users will be logged out after a specific interval from the time they logged in, in our case it is set to timeout= "1" min.  &lt;p&gt;If you want you can encrypt the user's credentials using hash algorithm like SHA1 etc. but it is not in the agenda of this blog.  &lt;p&gt;I won't go much&amp;nbsp;into the details about the settings here since you will get tonnes of articles on implementing forms based authentication on the net.  &lt;p&gt;I will basically show you how Request/Response flow occurs between the server and the client during Forms based authentication.  &lt;p&gt;&lt;em&gt;&lt;u&gt;Here we go:&lt;/u&gt;&lt;/em&gt;  &lt;p&gt;Step 1: Client sends a web request for the Default.aspx (&lt;em&gt;or any page of your choice in the website except the login page; who would prefer to go through a login page to access&amp;nbsp;one's desired webpage if given a chance :-)&lt;/em&gt;)&amp;nbsp;page to the&amp;nbsp;server.  &lt;p&gt;[You can focus only on the bold headers for our purpose]  &lt;p&gt;You type in the following url in the IE browser, &lt;a href="http://saurabsi-sec/FormsAuthentication/default.aspx" mce_href="http://saurabsi-sec/FormsAuthentication/default.aspx"&gt;http://saurabsi-sec/FormsAuthentication/default.aspx&lt;/a&gt; and hit &lt;font color="#ff0000"&gt;&lt;strong&gt;Go!&lt;/strong&gt;&lt;/font&gt;  &lt;p&gt;&lt;u&gt;&lt;em&gt;From Client&lt;/em&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;GET /FormsAuthentication/default.aspx HTTP/1.1&lt;/strong&gt;&lt;br&gt;Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*&lt;br&gt;Accept-Language: en-us&lt;br&gt;UA-CPU: x86&lt;br&gt;Accept-Encoding: gzip, deflate&lt;br&gt;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 1.1.4322; InfoPath.2)&lt;br&gt;Host: saurabsi-sec&lt;br&gt;Proxy-Connection: Keep-Alive&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;em&gt;&lt;font color="#800040"&gt;&lt;/font&gt;&lt;/em&gt;&lt;/u&gt; &lt;p&gt;Step 2: Server sends a response back to the Client with a status 302 Object Moved:  &lt;p&gt;&lt;u&gt;&lt;em&gt;From Server&lt;/em&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;HTTP/1.1 302 Found&lt;/strong&gt;&lt;br&gt;Date: Thu, 19 Apr 2007 07:11:43 GMT&lt;br&gt;Server: Microsoft-IIS/6.0&lt;br&gt;X-Powered-By: ASP.NET&lt;br&gt;MicrosoftOfficeWebServer: 5.0_Pub&lt;br&gt;X-AspNet-Version: 2.0.50727&lt;br&gt;&lt;strong&gt;Location: /FormsAuthentication/login.aspx?ReturnUrl=%2fFormsAuthentication%2fdefault.aspx&lt;/strong&gt;&lt;br&gt;Cache-Control: private&lt;br&gt;Content-Type: text/html; charset=utf-8&lt;br&gt;Content-Length: 196&lt;/font&gt; &lt;/p&gt; &lt;p&gt;Notice the Response status code and the Location in the response header. Server says to the client that it (client)&amp;nbsp;needs to resend a request to the url mentioned in the Location header.  &lt;p&gt;Step 3: Client&amp;nbsp;then resends&amp;nbsp;a new&amp;nbsp;request&amp;nbsp;for a&amp;nbsp;/FormsAuthentication/login.aspx?ReturnUrl=%2fFormsAuthentication%2fdefault.aspx&lt;br&gt;page. Now here since the client has to first get to the login.aspx page it will send a GET request first and not a POST request. Remember the first request to any site will be a GET and not POST.  &lt;p&gt;&lt;u&gt;&lt;em&gt;From Client&lt;/em&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;GET /FormsAuthentication/login.aspx?ReturnUrl=%2fFormsAuthentication%2fdefault.aspx HTTP/1.1&lt;/strong&gt;&lt;br&gt;Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*&lt;br&gt;Accept-Language: en-us&lt;br&gt;UA-CPU: x86&lt;br&gt;Accept-Encoding: gzip, deflate&lt;br&gt;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 1.1.4322; InfoPath.2)&lt;br&gt;Host: saurabsi-sec&lt;br&gt;Proxy-Connection: Keep-Alive&lt;/font&gt; &lt;/p&gt; &lt;p&gt;Remember the querystring &lt;em&gt;&lt;strong&gt;ReturnUrl&lt;/strong&gt;&lt;/em&gt; shows the original requested page. Client is supposed to send a request later after authentication is done to this&amp;nbsp;page. This is the way how the request/response maintains a track of the requested page throughout the transaction.  &lt;p&gt;Step 4: Server sends back the requested login.aspx page with a 200 OK Response.  &lt;p&gt;&lt;em&gt;&lt;u&gt;From Server&lt;/u&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;HTTP/1.1 200 OK&lt;/strong&gt;&lt;br&gt;Date: Thu, 19 Apr 2007 07:11:43 GMT&lt;br&gt;Server: Microsoft-IIS/6.0&lt;br&gt;X-Powered-By: ASP.NET&lt;br&gt;MicrosoftOfficeWebServer: 5.0_Pub&lt;br&gt;X-AspNet-Version: 2.0.50727&lt;br&gt;&lt;strong&gt;Set-Cookie: AppSessionCookie=vtd2qg55mkcypqnn53obxm45; path=/; HttpOnly&lt;/strong&gt;&lt;br&gt;Cache-Control: private&lt;br&gt;Content-Type: text/html; charset=utf-8&lt;br&gt;Content-Length: 1427&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Notice that Session ID gets created at this stage by the server and is sent along with the response to the client. From now onwards Server will keep track of a user's session using this cookie. Note the session ID gets created at this stage&amp;nbsp;and not the authentication cookie. Remember Session key gets created the moment a successful transaction&amp;nbsp;occurs like a 200 OK between the server and the client.  &lt;p&gt;Step 5: Now the client has recieved the login.aspx page. It enters the credentials for username and password and sends it across to the server again. Notice that this is a POST request&amp;nbsp;to the login.aspx page now&amp;nbsp;and this time&amp;nbsp;it also sends credentials like username and password. We are sending the username and password as part of the Body of the request and not as part of the header.  &lt;p&gt;&lt;u&gt;&lt;em&gt;From Client&lt;/em&gt;&lt;/u&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;POST /FormsAuthentication/login.aspx?ReturnUrl=%2fFormsAuthentication%2fdefault.aspx HTTP/1.1&lt;/strong&gt;&lt;br&gt;Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*&lt;br&gt;&lt;strong&gt;Referer:&lt;/strong&gt; &lt;/font&gt;&lt;a href="http://saurabsi-sec/FormsAuthentication/login.aspx?ReturnUrl=%2fFormsAuthentication%2fdefault.aspx" mce_href="http://saurabsi-sec/FormsAuthentication/login.aspx?ReturnUrl=%2fFormsAuthentication%2fdefault.aspx"&gt;&lt;font color="#ff0000"&gt;http://saurabsi-sec/FormsAuthentication/login.aspx?&lt;strong&gt;ReturnUrl=%2fFormsAuthentication%2fdefault.aspx&lt;/strong&gt;&lt;/font&gt;&lt;/a&gt;&lt;br&gt;&lt;font color="#ff0000"&gt;Accept-Language: en-us&lt;br&gt;Content-Type: application/x-www-form-urlencoded&lt;br&gt;UA-CPU: x86&lt;br&gt;Accept-Encoding: gzip, deflate&lt;br&gt;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 1.1.4322; InfoPath.2)&lt;br&gt;Proxy-Connection: Keep-Alive&lt;br&gt;Content-Length: 277&lt;br&gt;Host: saurabsi-sec&lt;br&gt;Pragma: no-cache&lt;br&gt;&lt;strong&gt;Cookie: AppSessionCookie=vtd2qg55mkcypqnn53obxm45&lt;/strong&gt; &lt;/font&gt; &lt;p&gt;You have the option of sending it as a querystring too, in such a case it will form a part of the request header and not body.  &lt;p&gt;If you check the Queystring here, it shows ReturnUrl=/FormsAuthentication/default.aspx  &lt;p&gt;Also checking the forms body, we find:  &lt;p&gt;txtUser=john&lt;br&gt;txtPassword=test1&lt;br&gt;cmdLogin=Login  &lt;p&gt;Step 6: Server receives the credentials and then goes ahead and authenticates the user. Once the user has been authenticated server responds back with a 302 Found response ,asking the client to send another request for the originally requested page, i.e. Default.aspx. How it determines the original requested page as default.aspx? You are right, it's through the querystring that we just discussed above.  &lt;p&gt;&lt;u&gt;&lt;em&gt;From Server&lt;/em&gt;&lt;/u&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;HTTP/1.1 302 Found&lt;/strong&gt;&lt;br&gt;Date: Thu, 19 Apr 2007 07:11:50 GMT&lt;br&gt;Server: Microsoft-IIS/6.0&lt;br&gt;X-Powered-By: ASP.NET&lt;br&gt;MicrosoftOfficeWebServer: 5.0_Pub&lt;br&gt;X-AspNet-Version: 2.0.50727&lt;br&gt;&lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;Location: /FormsAuthentication/default.aspx&lt;br&gt;Set-Cookie:&lt;/strong&gt; &lt;strong&gt;FormsAuthCookie=82A747623272A0A3A0C36EC6AD1FBA35A47592B1CFB38E54A1A7C5BC24ECAA2563715D4225EAE8927B98EC3DAD6FB9875E67FCA344AECCA19837A40B2311E373;&lt;/strong&gt; &lt;strong&gt;path=/; HttpOnly&lt;/strong&gt;&lt;br&gt;Cache-Control: private&lt;br&gt;Content-Type: text/html; charset=utf-8&lt;br&gt;Content-Length: 1590&lt;/font&gt;  &lt;p&gt;Notice the FormsAuthCookie here, this has been set by the server once it authenticates the user. Server goes ahead and sends back this authentication cookie along with the response back to the client. Now next time the client sends back any request in the same session it should have the authentication cookie as well apart from the Session Cookie that was set earlier. Server will recognize the user and the ongoing session with the client based on the cookies sent to it in future requests.  &lt;p&gt;Step 7: Now is the final round wherein Client after&amp;nbsp;done with all the validation process etc, goes ahead and sends&amp;nbsp;request for the Default.aspx page (remember it was also the very first&amp;nbsp;request sent by the client in the whole process).  &lt;p&gt;&lt;u&gt;&lt;em&gt;From client&lt;/em&gt;&lt;/u&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;GET /FormsAuthentication/default.aspx HTTP/1.1&lt;/strong&gt;&lt;br&gt;Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*&lt;br&gt;&lt;strong&gt;Referer: &lt;/strong&gt;&lt;/font&gt;&lt;a href="http://saurabsi-sec/FormsAuthentication/login.aspx?ReturnUrl=%2fFormsAuthentication%2fdefault.aspx" mce_href="http://saurabsi-sec/FormsAuthentication/login.aspx?ReturnUrl=%2fFormsAuthentication%2fdefault.aspx"&gt;&lt;font color="#ff0000"&gt;http://saurabsi-sec/FormsAuthentication/login.aspx?ReturnUrl=%2fFormsAuthentication%2fdefault.aspx&lt;/font&gt;&lt;/a&gt;&lt;br&gt;&lt;font color="#ff0000"&gt;Accept-Language: en-us&lt;br&gt;UA-CPU: x86&lt;br&gt;Accept-Encoding: gzip, deflate&lt;br&gt;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 1.1.4322; InfoPath.2)&lt;br&gt;Proxy-Connection: Keep-Alive&lt;br&gt;Host: saurabsi-sec&lt;br&gt;Pragma: no-cache&lt;br&gt;&lt;strong&gt;Cookie: AppSessionCookie=vtd2qg55mkcypqnn53obxm45; FormsAuthCookie=82A747623272A0A3A0C36EC6AD1FBA35A47592B1CFB38E54A1A7C5BC24ECAA2563715D4225EAE8927B98EC3DAD6FB9875E67FCA344AECCA19837A40B2311E373&lt;/strong&gt;&lt;/font&gt;  &lt;p&gt;Notice the cookies here. You will see there are two cookies being sent to the server separated by ";".&amp;nbsp;One for the server to recognize the ongoing session with the client and the other one to recongize the authenticated user.  &lt;p&gt;Step 8: Server has nothing else to do&amp;nbsp;much but send back the response to the client for the requested web page.  &lt;p&gt;&lt;em&gt;&lt;u&gt;From Server&lt;/u&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;HTTP/1.1 200 OK&lt;/strong&gt;&lt;br&gt;Date: Thu, 19 Apr 2007 07:11:50 GMT&lt;br&gt;Server: Microsoft-IIS/6.0&lt;br&gt;X-Powered-By: ASP.NET&lt;br&gt;MicrosoftOfficeWebServer: 5.0_Pub&lt;br&gt;X-AspNet-Version: 2.0.50727&lt;br&gt;Cache-Control: private&lt;br&gt;Content-Type: text/html; charset=utf-8&lt;br&gt;Content-Length: 1111&lt;/font&gt;&lt;/p&gt; &lt;p&gt;You might notice something here, in the web.config file we had set the timeout value for Forms authentication cookie to be 1 minute, and session cookie to be 2 minutes. So, you might see a scenario wherein let's say a user gets logged out because of expired authentication cookie. In our example let's say a user gets logged out after 1 minute (authentication cookie timeout value being set to 1 minute), and he is redirected to login page. He logs in back this time after entering the credentials in the login page. But this time he uses a different credentials to login.  &lt;p&gt;So what should happen, should the new user (with a different credentials this time) have access to all the original session variables (assuming session timeout has still not expired for the earlier user session) of the previous user&amp;nbsp;when the same browser instance is running?  &lt;p&gt;Answer is Yes, the new user with a different credentials this time will have access to all the session variables for the previous user, provided the same browser session is being used this time. Resaon being that the authentication cookie has expired but not the session cookie, so browser sends the vaild session cookies to the server and hence is able to access the session variables.  &lt;p&gt;If we use a different browser session, of course a new session cookie has to be obtained which will invalidate session variables for the prevoius user.  &lt;p&gt;Here&amp;nbsp;I haven't gone into troubleshooting session loss issues, rather i have focused on how forms authentication process occurs between client and the server. In case your eyes are looking for some good logical reading on troubleshooting Session loss issues in ASP.Net, a must READ&amp;nbsp;here &lt;a title="http://aspalliance.com/1182_Troubleshooting_Session_Related_Issues_in_ASPNET" href="http://aspalliance.com/1182_Troubleshooting_Session_Related_Issues_in_ASPNET" mce_href="http://aspalliance.com/1182_Troubleshooting_Session_Related_Issues_in_ASPNET"&gt;http://aspalliance.com/1182_Troubleshooting_Session_Related_Issues_in_ASPNET&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2190044" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://blogs.msdn.com/saurabh_singh/archive/tags/Forms+Authentication/default.aspx">Forms Authentication</category></item></channel></rss>