<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Carmelo Pulvirenti&amp;#39;s Blog</title><subtitle type="html">Everything you should know about .NET and Web Development</subtitle><id>http://blogs.msdn.com/b/carmelop/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/carmelop/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2012-11-13T18:05:00Z</updated><entry><title>System.BadImageFormatException: Bad IL Range – what it is going on!</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2013/06/13/system-badimageformatexception-bad-il-range-what-it-is-going-on.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2013/06/13/system-badimageformatexception-bad-il-range-what-it-is-going-on.aspx</id><published>2013-06-13T06:47:00Z</published><updated>2013-06-13T06:47:00Z</updated><content type="html">&lt;p&gt;Dear friends, today I want to share with you an important error that you should always take care about: &lt;strong&gt;System.BadImageFormatException&lt;/strong&gt;. Please, please please take care of this exception, especially on scenarios where you think that it is not part of the problem &lt;img class="wlEmoticon wlEmoticon-smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/5123.wlEmoticon_2D00_smile_5F00_3B4D2AD2.png" alt="Sorriso" /&gt;. As usual, a very short background that can give you an idea of how important this exception is:&lt;/p&gt;
&lt;p&gt;An ASP.NET application of my customer sometimes raises an exception of the following type System.NullReferenceException during its start-up. To be very very short, after hours and hours of debug, we found out that customer&amp;rsquo;s applications does not work properly (raising System.NullReferenceException) since during initial steps a &lt;strong&gt;System.BadImageFormatException&lt;/strong&gt; occurs.&lt;/p&gt;
&lt;p&gt;To figure out this was very complex: IIS by default handles the exception avoiding that w3wp.exe process crashes. Furthermore the&lt;strong&gt; &lt;/strong&gt;System.NullReferenceException does not have any apparent relation with previous exception.&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The question was: Why do we get a System.BadImageFormatException: &lt;strong&gt;Bad IL Range?&lt;/strong&gt; According to our &lt;a href="http://msdn.microsoft.com/en-us/library/system.badimageformatexception.aspx"&gt;documentation&lt;/a&gt;, this exception comes out for the following scenarios:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;&amp;ldquo;&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;The exception that is thrown when the file image of a dynamic link library (DLL) or an executable program is invalid.&lt;strong&gt;&amp;rdquo;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;And Bad IL Range means that a section of IL code inside a specific dll is not valid.&lt;/p&gt;
&lt;p&gt;How is it possible? Is there a bug on C# compiler or VB.NET one? Of course no! To avoid a file/dll corruption, I asked customer to generate the DLLs one more time but issue was always there. Typically this step is enough to solve this kind of trouble.&lt;/p&gt;
&lt;p&gt;Problem was always there since customer&amp;rsquo;s compilation process includes a 3&lt;sup&gt;rd&lt;/sup&gt; step. Typically we have two steps: .NET Language &amp;gt;&amp;gt; MS Intermediate Language &amp;gt;&amp;gt; native code. My customer does something more: .NET Language &amp;gt;&amp;gt; MS Intermediate Language &amp;gt;&amp;gt;&lt;strong&gt; Obfuscator&lt;/strong&gt; &amp;gt;&amp;gt; native code.&lt;/p&gt;
&lt;p&gt;Basically the managed dll (generated by C# compiler) was edited/recompiled by &lt;a href="http://en.wikipedia.org/wiki/Obfuscation_(software)"&gt;obfuscator application&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I do not want to mention here what obfuscator my customer was using. It is not relevant. The point was that this obfuscator generates an invalid IL so at runtime we got that exception System.BadImageFormatException.&lt;/p&gt;
&lt;p&gt;Unfortunately application does not crash due to reason mentioned above so later on its execution time we got unpredictable behavior that generates a different exception&lt;strong&gt; &lt;/strong&gt;System.NullReferenceException.&lt;/p&gt;
&lt;p&gt;If you have this kind of issue, try to isolate the trouble reducing the external factors: in this case the obfuscator software.&lt;/p&gt;
&lt;p&gt;Enjoy your .NET coding.&lt;img class="wlEmoticon wlEmoticon-winkingsmile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/8171.wlEmoticon_2D00_winkingsmile_5F00_5A8FD1A5.png" alt="Occhiolino" /&gt;&lt;/p&gt;
&lt;p&gt;Carmelo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10425554" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term=".NET" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/-NET/" /></entry><entry><title>IIS - site offline but handshake phase done properly</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2013/05/25/iis-site-offline-but-handshake-phase-done-properly.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2013/05/25/iis-site-offline-but-handshake-phase-done-properly.aspx</id><published>2013-05-25T16:55:58Z</published><updated>2013-05-25T16:55:58Z</updated><content type="html">&lt;p&gt;Today I want to share with you an interesting scenario introduced by one of my customers. Let me give you a picture about where we are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We have a Web Server with two ip addresses configured on top of it.&lt;/li&gt;    &lt;li&gt;Two web sites are hosted on mentioned Web Server. Let’s call them site1 and site2. Both sites are available over HTTPs to final users and each site uses is own ip address. To be clear:&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;Site1 – ip1:443&lt;/li&gt;      &lt;li&gt;Site2 – ip2:443&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;In case that you configure one of your web sites offline (basically you stop it), IIS participates to SSL handshake phase &lt;a href="http://support.microsoft.com/kb/257591/en-gb"&gt;http://support.microsoft.com/kb/257591/en-gb&lt;/a&gt; even if associated site is off line.&lt;/p&gt;  &lt;p&gt;As results, IIS sends out the SSL certificate to final user and after that an HTTP 404. How is it possible? Let’s try to answer about this question:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://support.microsoft.com/kb/175952/en-gb"&gt;http://support.microsoft.com/kb/175952/en-gb&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;“The Winsock application that is listening on the designated port &lt;b&gt;was written so that it binds to any local IP address by using INADDR_ANY&lt;/b&gt;. This means that the application will listen to all local interfaces and you can connect to the port of any of them. This is why netstat -an shows IP address 0.0.0.0 listening on the port.”&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/i&gt;&lt;/p&gt;  &lt;p&gt;What previous KB reports is clear: each time that an application defines a socket for a specific ip/port, Winsock takes care to listen for incoming requests to the specified port &lt;b&gt;without restricting&lt;/b&gt; this operation on a specified ip. This is the default behavior.&lt;/p&gt;  &lt;p&gt;Coming back to our scenario! Even if one site is stopped, the second one is working on port 443. What does it mean? Winsock listens on port 443. We can check this by running following command:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;i&gt;netstat -ano |findstr :443&lt;/i&gt;&lt;/p&gt;    &lt;p&gt;&lt;i&gt; TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 4&lt;/i&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;As soon as an incoming connection comes-in for off line site, it finds-out a process who is listening on this port on server side: Winsock. This one completes the handshake phase sending out the configured SSL certificate to client. After handshake phase is completed, the request is moved to IIS so it answers with 404.&lt;/p&gt;  &lt;p&gt;Is it possible to avoid this? Yes of course, by instructing WinSock to listen only the specified ip instead of all available IPs on the machine: &lt;a href="http://support.microsoft.com/kb/954874/en-gb"&gt;http://support.microsoft.com/kb/954874/en-gb&lt;/a&gt;. In our case:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;netsh http add iplisten ip1&lt;/p&gt;    &lt;p&gt;netsh http add iplisten ip2&lt;/p&gt;    &lt;p&gt;properly restart the services.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Of course after stopping web site, we have to instruct Winsock to not listen incoming connections on the web site ip:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;netsh http del iplisten xxx.xxx.x.x&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Enjoy your IIS administration! &lt;img class="wlEmoticon wlEmoticon-hotsmile" style="style" alt="Hot smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/6675.wlEmoticon_2D00_hotsmile_5F00_1B9149F4.png" /&gt;&lt;/p&gt;  &lt;p&gt;Carmelo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10421333" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term="IIS" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/IIS/" /></entry><entry><title>404 File not found due to FileUtil.CheckSuspiciousPhysicalPath</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2013/05/09/404-file-not-found-due-to-fileutil-checksuspiciousphysicalpath.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2013/05/09/404-file-not-found-due-to-fileutil-checksuspiciousphysicalpath.aspx</id><published>2013-05-09T20:04:11Z</published><updated>2013-05-09T20:04:11Z</updated><content type="html">&lt;p&gt;As everyone of you knows, 404 means file not found! A complete reference is available here: &lt;a href="http://support.microsoft.com/kb/943891/en-gb"&gt;http://support.microsoft.com/kb/943891/en-gb&lt;/a&gt;. Well, there is a scenario where IIS provides back an HTTP 404 even if your file is there! Unbelievable.. Let us have a look to it. First of all, proceed configuring web server to provide back this code, after that let’s see where the issue is! Define a web site on IIS and configure its path on a system driver, for example E:. After that, define a web application inside it. Store web application files inside the same drive folder. For example E:\TestMicrosoft. This is my configuration:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/5001.clip_5F00_image002_5F00_3D3C287E.jpg"&gt;&lt;img title="clip_image002" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image002" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/2055.clip_5F00_image002_5F00_thumb_5F00_310A888A.jpg" width="519" height="105" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As you can see, I added a txt resource and an ASP.NET page. If you navigate to web: &lt;a href="http://localhost/TestCarmelop/example.aspx"&gt;http://localhost/TestCarmelop/example.aspx&lt;/a&gt; IIS answers with an HTTP 404. This behavior does not occurs for a resource not handled by ASP.NET ISAPI &lt;a href="http://localhost/TestCarmelop/test.txt"&gt;http://localhost/TestCarmelop/test.txt&lt;/a&gt;. Why? A good way to understand it is by enabling the Failed Request Tracing Rules: &lt;a href="http://www.iis.net/learn/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis"&gt;http://www.iis.net/learn/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Reading the trace, we can find out the following information:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/8306.clip_5F00_image004_5F00_54E33A17.jpg"&gt;&lt;img title="clip_image004" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image004" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/5670.clip_5F00_image004_5F00_thumb_5F00_46581825.jpg" width="556" height="107" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;It seems that during the request, processing and exception occurred. Let us have a look to .NET source code ( you can use reflector on ILSPY for example). In my case, application is running on top of .Net Framework 2.0, so I will refer these assemblies. Please have a look at code mentioned below.&lt;/p&gt;  &lt;p&gt;As you can see from above call stack, ASP.NET ISAPI invokes method: &lt;b&gt;System.Web.CachedPathData.GetConfigPathData. &lt;/b&gt;This is done to get the upper level hierarchy settings. From this method, we jump to FileUtil.CheckSuspiciousPhysicalPath and there our path is considered suspect by ASP.NET runtime. So an exception is thrown: &lt;b&gt;throw&lt;/b&gt; &lt;b&gt;new&lt;/b&gt; &lt;b&gt;HttpException&lt;/b&gt;(404, string.Empty); It is exactly our HTTP status code! The question is: Why our path is considered suspected? If we collect a memory dump, we can see that the value of path analyzed is E:\. This path is considered suspect in consideration of fact that you can access to every location of the entire drive. The solution, is to move the web site definition in a driver folder, something like E:\Mysite.&lt;/p&gt;  &lt;p&gt;Enjoy your debug &lt;img class="wlEmoticon wlEmoticon-winkingsmile" style="style" alt="Winking smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/1447.wlEmoticon_2D00_winkingsmile_5F00_63118D3A.png" /&gt;&lt;/p&gt;  &lt;p&gt;Carmelo&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;     &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// System.Web.CachedPathData&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; CachedPathData GetConfigPathData(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; configPath)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; key = CachedPathData.CreateKey(configPath);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    CacheInternal cacheInternal = HttpRuntime.CacheInternal;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    CachedPathData cachedPathData = (CachedPathData)cacheInternal.Get(key);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (cachedPathData != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        cachedPathData.WaitForInit();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; cachedPathData;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    CachedPathData parentData = &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    CacheDependency cacheDependency = &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    VirtualPath virtualPath = &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; text = &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; flag = &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;[] filenames = &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;[] cachekeys = &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; text2 = &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; flag2 = &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (WebConfigurationHost.IsMachineConfigPath(configPath))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        flag = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        flag2 = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; parent = ConfigPathUtility.GetParent(configPath);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        parentData = CachedPathData.GetConfigPathData(parent);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; text3 = CachedPathData.CreateKey(parent);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        cachekeys = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;[]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            text3&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (!WebConfigurationHost.IsVirtualPathConfigPath(configPath))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            flag = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            flag2 = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            WebConfigurationHost.GetSiteIDAndVPathFromConfigPath(configPath, &lt;span style="color: rgb(0, 0, 255);"&gt;out&lt;/span&gt; text2, &lt;span style="color: rgb(0, 0, 255);"&gt;out&lt;/span&gt; virtualPath);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                text = virtualPath.MapPathInternal(&lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt; (HttpException ex)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (ex.GetHttpCode() == 500)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                    &lt;span style="color: rgb(0, 0, 255);"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; HttpException(404, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;.Empty);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;throw&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;font style="background-color: rgb(255, 255, 0);"&gt;FileUtil.CheckSuspiciousPhysicalPath(text);&lt;/font&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; flag3 = &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;.IsNullOrEmpty(text))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                flag = &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                FileUtil.PhysicalPathStatus(text, &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;out&lt;/span&gt; flag, &lt;span style="color: rgb(0, 0, 255);"&gt;out&lt;/span&gt; flag3);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (flag &amp;amp;&amp;amp; !flag3)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;....&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// System.Web.Util.FileUtil&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;font style="background-color: rgb(255, 255, 0);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;internal&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; CheckSuspiciousPhysicalPath(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; physicalPath)&lt;/font&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (FileUtil.IsSuspiciousPhysicalPath(physicalPath))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; HttpException(404, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;.Empty);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10417432" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term="IIS" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/IIS/" /></entry><entry><title>How to monitor Application Request Routing via PowerShell</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2013/04/29/how-to-monitor-application-request-routing-via-powershell.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2013/04/29/how-to-monitor-application-request-routing-via-powershell.aspx</id><published>2013-04-29T20:15:45Z</published><updated>2013-04-29T20:15:45Z</updated><content type="html">&lt;p&gt;Dear readers,&lt;/p&gt;  &lt;p&gt;Welcome back&lt;img class="wlEmoticon wlEmoticon-winkingsmile" style="style" alt="Winking smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/4527.wlEmoticon_2D00_winkingsmile_5F00_44A42428.png" /&gt;. Today I want to discuss with you how to monitor Application Request Routing via PowerShell script. In case that you are wondering what ARR is, probably you have to give a look at following link: &lt;a href="http://www.iis.net/downloads/microsoft/application-request-routing"&gt;http://www.iis.net/downloads/microsoft/application-request-routing&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Of course ARR has some tools and performance counters available to monitor its status, like:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.iis.net/learn/extensions/configuring-application-request-routing-(arr)/using-performance-counters"&gt;ARR performance counter&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ee683930(v=ws.10).aspx"&gt;ARR monitoring and management over UI&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Anyway, there are scenarios where it is required a script to monitor how ARR server and application servers work. In a scenario like this, you could use PowerShell. The following example shows an example of script. &lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;     &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;#####################################################################################&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;# THIS IS SAMPLE CODE AND IS ENTIRELY UNSUPPORTED. THIS CODE AND INFORMATION        #&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;# IS PROVIDED &amp;quot;AS-IS&amp;quot; WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,    #&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;# INCLUDING BUT NOT LIMITED TO AN IMPLIED WARRANTY OF MERCHANTABILITY AND/OR        #&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;# FITNESS FOR A PARTICULAR PURPOSE.                                                 #&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;#####################################################################################&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;# First add a reference to the MWA dll&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;$dll=[System.Reflection.Assembly]::LoadWithPartialName(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Microsoft.Web.Administration&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;#Get the manager and config object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;$mgr = new-object Microsoft.Web.Administration.ServerManager&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;$conf = $mgr.GetApplicationHostConfiguration()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;#Get the webFarms section&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;$section = $conf.GetSection(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;webFarms&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;$webFarms = $section.GetCollection()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;foreach&lt;/span&gt; ($webFarm &lt;span style="color: rgb(0, 0, 255);"&gt;in&lt;/span&gt; $webFarms)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    $Name= $webFarm.GetAttributeValue(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;#Get the servers in the farm&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    $servers = $webFarm.GetCollection()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    Write-Host  &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Farm Name: &amp;quot;&lt;/span&gt; $Name&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;foreach&lt;/span&gt;($server &lt;span style="color: rgb(0, 0, 255);"&gt;in&lt;/span&gt; $servers)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;         $ip= $server.GetAttributeValue(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;address&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;         &lt;span style="color: rgb(0, 128, 0);"&gt;#Get the ARR section&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;         $arr = $server.GetChildElement(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;applicationRequestRouting&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;         $counters = $arr.GetChildElement(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;counters&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;         $isHealthy=$counters.GetAttributeValue(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;isHealthy&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;         $state= $counters.GetAttributeValue(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;state&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;switch&lt;/span&gt; ($state) &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;         { &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                0 {$state= &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Available&amp;quot;&lt;/span&gt;} &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                1 {$state= &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Drain&amp;quot;&lt;/span&gt;} &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                2 {$state= &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Unavailable&amp;quot;&lt;/span&gt;} &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;default&lt;/span&gt; {$state= &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Non determinato&amp;quot;&lt;/span&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;( $isHealthy)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            $isHealthy=&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Healthy&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            $isHealthy=&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Not Healthy&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        }        &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;         Write-Host -NoNewLine $ip  &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot; &amp;quot;&lt;/span&gt; $state &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot; &amp;quot;&lt;/span&gt; $isHealthy&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;         &lt;span style="color: rgb(0, 128, 0);"&gt;#NEW LINE&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;         Write-Host&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;#NEW LINE&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    Write-Host&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Output shows all web farms installed on your server plus the status of each application server.&lt;/p&gt;

&lt;p&gt;Enjoy your script&lt;/p&gt;

&lt;p&gt;HTH
  &lt;br /&gt;Carmelo &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10414879" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term="IIS" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/IIS/" /></entry><entry><title>How many web applications per application pool</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2013/03/22/how-many-web-applications-per-application-pool.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2013/03/22/how-many-web-applications-per-application-pool.aspx</id><published>2013-03-22T17:28:00Z</published><updated>2013-03-22T17:28:00Z</updated><content type="html">&lt;p&gt;Many times during my work activities, I figure out wrong configurations on web servers. Today, I want to discuss here this topic: web applications cannot be managed and configured like traditional windows applications.&lt;/p&gt;
&lt;p&gt;When we think to desktop applications like notepad, we know that each time we run it, O.S. defines a new process (notepad.exe in our example).&lt;/p&gt;
&lt;p&gt;Is it true for web application? No, a web application needs a host process to be executed, it means a process that carries on the web application and allows its execution. Starting from IIS6 this process is called w3wp.exe. &lt;br /&gt;Please pay attention, a web application runs on top of an application pool that you define in IIS. An application pool, can be associated to one or more worker process.&lt;/p&gt;
&lt;p&gt;A typical mistake is the following: web server administrator defines an application pool and execute many web applications on top of it. I worked with customer who has 20 -30-web applications on top of a single application pool! &lt;img class="wlEmoticon wlEmoticon-surprisedsmile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/0844.wlEmoticon_2D00_surprisedsmile_5F00_5A3C5EC9.png" alt="Surprised smile" /&gt; &lt;br /&gt;This is bad very bad especially for 32 bit process. Let me try to explain why. Every web application needs:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;1. Assemblies loaded in memory&lt;/p&gt;
&lt;p&gt;2. Memory to calculate the application goal.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In case that you define a single application pool for all web applications, what happens is that all web apps have to load their assemblies and share the same memory. Do you think that this memory is infinite? No, it is not.&lt;/p&gt;
&lt;p&gt;In a 32-bit process, by default every application can allocate 2GB of memory and a 32-bit process on a 64 bit machine 4GB. Those values are the maximum ones available by default, but do not except to use all that memory.&lt;/p&gt;
&lt;p&gt;Typically, an Out Of Memory exception occurs before that value. It happens due to internal memory fragmentation!&lt;/p&gt;
&lt;p&gt;In case that your application are managed one: ASP.NET to be clear, what happened is that Garbage Collector takes care to clean up the memory. If all web applications share the same memory, this one is under pressure. &lt;br /&gt;It means that GC runs a lot of time per second in order to provide clean memory to your app. What is the side effect? In server mode, garbage collector requires to stop all threads activities to clean up the memory (this was improved on .NET Fx 4.5, where the collation does not require to stop all threads). What is the side effect?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Slow performance of your web application&lt;/li&gt;
&lt;li&gt;High impact on CPU time due to GC&amp;rsquo;s activity.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Furthermore, if one of your web application crashes, all application running on the same pool will be impacted. Nothing more? There are other things to consider:&lt;/p&gt;
&lt;p&gt;Threadpool, the number of thread that single process can define is not infinite. So all web application have to share that number/threads. Same thing for connection pool and so on.&lt;/p&gt;
&lt;p&gt;Please do not consider this post in the following way: define necessarily one application pool per web application. This is not the goal, IIS gives you the flexibility to host multiple applications on the same application pool. However, when you decide how many applications have to run on top of the same application pool, take care of above considerations. &lt;img class="wlEmoticon wlEmoticon-winkingsmile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/0842.wlEmoticon_2D00_winkingsmile_5F00_2BE2D91C.png" alt="Winking smile" /&gt;&lt;/p&gt;
&lt;p&gt;HTH, &lt;br /&gt;Carmelo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10404629" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term="IIS" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/IIS/" /></entry><entry><title>My first Windows 8 App on Store</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2013/03/10/my-first-windows-8-app-on-store.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2013/03/10/my-first-windows-8-app-on-store.aspx</id><published>2013-03-10T16:54:00Z</published><updated>2013-03-10T16:54:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Dear friends,&lt;/p&gt;
&lt;p&gt;Today I&amp;rsquo;m going to publish my first windows 8 app on my country store: Italy. Unfortunately it means that only someone of you could play with it, sorry for that. Anyway, application is nothing of special, just a television guide.&lt;/p&gt;
&lt;p&gt;In order to follow our privacy guideline: &lt;a href="http://blogs.msdn.com/b/jennifer/archive/2012/11/15/common-windows-store-certification-errors-4-1-your-app-must-comply-with-privacy-requirements.aspx"&gt;http://blogs.msdn.com/b/jennifer/archive/2012/11/15/common-windows-store-certification-errors-4-1-your-app-must-comply-with-privacy-requirements.aspx&lt;/a&gt;, I&amp;rsquo;m going to mention here the privacy term of my App.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Guida Televisiva Application does not store\share or use any final user&amp;rsquo;s information&lt;/li&gt;
&lt;li&gt;Guida Televisiva Application needs to access over the web just to get the list of television programs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let me share here the same information in Italian:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;L&amp;rsquo;applicazione guida televisiva non memorizza\condivide oppure utilizza dati del suo utilizzatore.&lt;/li&gt;
&lt;li&gt;L&amp;rsquo;applicazione guida televisiva ha la necessit&amp;agrave; di accedere ad internet solamente per recuperare la lista dei programmi televisivi.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Application is available here: &lt;a href="http://apps.microsoft.com/windows/it-IT/app/guida-televisiva/a7cb88e7-5fa0-4457-a926-a6a1d24a0065"&gt;http://apps.microsoft.com/windows/it-IT/app/guida-televisiva/a7cb88e7-5fa0-4457-a926-a6a1d24a0065&lt;/a&gt;&amp;nbsp;for free&lt;/p&gt;
&lt;p&gt;Thx,&lt;/p&gt;
&lt;p&gt;Carmelo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10400966" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term="App Store" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/App+Store/" /></entry><entry><title>StackOverflow Exception – wrong implementation or leak of resources</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2013/03/03/stackoverflow-exception-wrong-implementation-or-leak-of-resources.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2013/03/03/stackoverflow-exception-wrong-implementation-or-leak-of-resources.aspx</id><published>2013-03-03T20:22:15Z</published><updated>2013-03-03T20:22:15Z</updated><content type="html">&lt;p&gt;During this week, I had the opportunity to analyze a very interesting trouble and I want to share it with all of you. I do not want to go too much in deep about what occurred on the real scenario otherwise you could consider this post very long and boring. My idea is to share here some concepts:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;A StackOverflow exception occurs when your code uses all resources available for stack. So, the first consideration to keep in mind is this one: What is the size of my call stack?      &lt;br /&gt;There is a public KB that answers to this question &lt;a href="http://support.microsoft.com/kb/932909/en-gb"&gt;http://support.microsoft.com/kb/932909/en-gb&lt;/a&gt; concerning w3wp.exe (process who hosts our web page)&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;256 KB for 32 bit process&lt;/li&gt;      &lt;li&gt;512 KB for 64 bit process&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;The common mistake concerning StackOverflow exception is to write down a recursive function that never ends its work. In this scenario, it is expected to have this exception. Of course, I do not want to discuss here about an infinite recursive function… that is a bug and nothing more. Let’s consider to write down a function like this one:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;

&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;
  &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;
    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; DoWork1( &lt;span style="color: rgb(0, 0, 255);"&gt;long&lt;/span&gt; x)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (x == 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; DoWork1(x - 1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;According to input value, this function could grow-up in term of resources use in the stack. Let’s consider to have an application like this one:&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;
  &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;
    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Button1_Click(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;long&lt;/span&gt; input=10000;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    Work w = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Work(input);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ThreadStart threadDelegate = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ThreadStart(w.DoWork);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    Thread newThread = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Thread(threadDelegate);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    newThread.Start();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; Work&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;long&lt;/span&gt; i;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Work(&lt;span style="color: rgb(0, 0, 255);"&gt;long&lt;/span&gt; i)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.i = i;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DoWork()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; ouput=DoWork1(i);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; DoWork1( &lt;span style="color: rgb(0, 0, 255);"&gt;long&lt;/span&gt; x)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (x == 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; DoWork1(x - 1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;

&lt;p&gt;Since the input value is very high, this application will raise a StackOverflow Exception even if reading the code everything seem to be fine. We have a StackOverflow Exception because our code uses all available resources.&lt;/p&gt;

&lt;p&gt;Is there any possibility to fix it? Yes, of course otherwise I was not writing this post on my blog :-)..There are two possibilities to fix this issue:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Increase the stack size for all threads of your application: &lt;a href="http://blogs.msdn.com/b/tom/archive/2008/03/31/stack-sizes-in-iis-affects-asp-net.aspx"&gt;http://blogs.msdn.com/b/tom/archive/2008/03/31/stack-sizes-in-iis-affects-asp-net.aspx&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;Customize stack size for my thread “newThread”. 
    &lt;br /&gt;NET Thread API has a constructor that allows you to specify the maximum stack size to use &lt;a href="http://msdn.microsoft.com/en-us/library/5cykbwz4.aspx"&gt;http://msdn.microsoft.com/en-us/library/5cykbwz4.aspx&lt;/a&gt; 

    &lt;br /&gt;Changing the definition of my newThread in the following way:&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
  &lt;div id="codeSnippetWrapper"&gt;
    &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;
      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt; Thread newThread = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Thread(threadDelegate, 1048576);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;blockquote&gt;
  &lt;p&gt; The trouble is fixed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Please note that what I mentioned here is only a simplification of what could happen on a real web application. Consider stack limit especially when you write down your classes and attributes. This because on a real scenario, it could happens that 3&lt;sup&gt;rd&lt;/sup&gt; party code or .NET framework core dlls need to parse your code in a recursive way. If your classes include many members, a StackOverflow Exception could come out even if you do not expect it.&lt;/p&gt;

&lt;p&gt;Hope this help.&lt;/p&gt;

&lt;p&gt;Carmelo&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10398922" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term="IIS" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/IIS/" /></entry><entry><title>IIS7’s performance slower than IIS6</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2012/12/27/iis7-s-performance-slower-than-iis6.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2012/12/27/iis7-s-performance-slower-than-iis6.aspx</id><published>2012-12-27T16:45:53Z</published><updated>2012-12-27T16:45:53Z</updated><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;As Support Engineer, I have the possibility to work with many customers around the world with different configurations. A couple of mounts ago, I was surprised to work with one of them who sustained that after the migration to IIS7 from IIS6, the IIS7’s performance was worse than IIS6. The servers’ goal was the same: both of them access on the same remote share in order to provide images to final users. It means &lt;b&gt;no custom code was in execution&lt;/b&gt;: final users have the possibility to get their images simply opening urls like this one &lt;a href="http://serverName/myImage.jpg"&gt;http://serverName/myImage.jpg&lt;/a&gt; on their brewers.&lt;/p&gt;  &lt;p&gt;How was it possible? Was really IIS7 performing worse than IIS6? Of course no! The remote server (where the images were stored on) was the same for both web servers: IIS6 and II7. The network was working properly, let’s say with the same bandwidth, so where the issue was!?! &lt;/p&gt;  &lt;p&gt;After collecting a memory dump, everything was clear (as in most of cases &lt;img class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/6011.wlEmoticon_2D00_winkingsmile_5F00_7D4521BD.png" /&gt;). Well the threads were like this one:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;0:087&amp;gt; k
# ChildEBP RetAddr  
00 0671ed44 75c63bc8 ntdll!ZwDelayExecution+0x15
01 0671edac 75c64498 KERNELBASE!SleepEx+0x65
02 0671edbc 73c48765 KERNELBASE!Sleep+0xf
03 0671edf0 73c443c4 iisutil!CReaderWriterLock3::_LockSpin+0xfb
04 0671ee10 73beeb73 iisutil!CReaderWriterLock3::ReadLock+0x3c
05 0671ee18 73bf1b1b nativerd!CONFIG_CACHE::ReadLock+0x11
06 0671ee28 73bdaad0 nativerd!CONFIG_CACHE::GetConfigFileList(&lt;span class="kwrd"&gt;class&lt;/span&gt; PATH * pConfigPath = 0x0671ef14, unsigned &lt;span class="kwrd"&gt;long&lt;/span&gt; dwParseMode = 0x2a, &lt;span class="kwrd"&gt;class&lt;/span&gt; CONFIG_FILE_LIST * pConfigFileList = 0x0671ee4c, &lt;span class="kwrd"&gt;class&lt;/span&gt; PARSE_ERROR_INFO * pParseErrorInfo = 0x0671f0b8)+0xe
07 0671f26c 73bb896d nativerd!CONFIG_SYSTEM::GetUniqueConfigPath(wchar_t * bstrConfigPath = 0x0671f598 &lt;span class="str"&gt;&amp;quot;MACHINE/WEBROOT/APPHOST/SFTBS.SL.PT/auto/media/000561/Viaturas/000714130/166x125/Renault-Laguna-2357165.jpg&amp;quot;&lt;/span&gt;, wchar_t ** pbstrUniquePath = 0x0671f290)+0xba
08 0671f294 730a3ca5 nativerd!CONFIG_SYSTEM::GetUniqueConfigPath(wchar_t * pszConfigPath = 0x0671f598 &lt;span class="str"&gt;&amp;quot;MACHINE/WEBROOT/APPHOST/SFTBS.SL.PT/auto/media/000561/Viaturas/000714130/166x125/2357165.jpg&amp;quot;&lt;/span&gt;, wchar_t * pszUniqueConfigPath = 0x0671f798 &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, unsigned &lt;span class="kwrd"&gt;long&lt;/span&gt; * pcchUniqueConfigPath = 0x0671f2c0, &lt;span class="kwrd"&gt;class&lt;/span&gt; INativeSectionException ** ppException = 0x0671f9c4)+0x2809 0671f99c 730a547d iiscore!W3_CONTEXT::SetupMetadata+0x22b
0a 0671f9d0 730a5ab3 iiscore!W3_CONTEXT::SetupStateMachinePhase2+0x7e
0b 0671fa44 730a61c3 iiscore!W3_CONTEXT::SetupStateMachine+0x241
0c 0671fa58 730a6642 iiscore!W3_MAIN_CONTEXT::StartNotificationLoop+0x3f
0d 0671fa70 72ea1568 iiscore!W3_MAIN_CONTEXT::OnNewRequest+0x47
0e 0671fa7c 72ea14e6 w3dt!UL_NATIVE_REQUEST::DoStateProcess+0x26
0f 0671fa88 72ea154c w3dt!UL_NATIVE_REQUEST::DoWork+0x60
10 0671fa9c 7324265a w3dt!OverlappedCompletionRoutine+0x1a
11 0671fad4 7324289a w3tp!THREAD_POOL_DATA::ThreadPoolThread+0x89
12 0671fae8 73241e95 w3tp!THREAD_POOL_DATA::ThreadPoolThread+0x24
13 0671fb00 75b533aa w3tp!THREAD_MANAGER::ThreadManagerThread+0x39
14 0671fb0c 778a9ef2 kernel32!BaseThreadInitThunk+0xe
15 0671fb4c 778a9ec5 ntdll!__RtlUserThreadStart+0x70
16 0671fb64 00000000 ntdll!_RtlUserThreadStart+0x1b
&lt;/pre&gt;


&lt;p&gt;What were they doing? They were trying to get a configuration file. The fact is this one:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Starting form IIS 7, the web server’s pipeline changed including new features and new integration with .NET. 
    &lt;br /&gt;Even if customer was not using any feature of ASP.Net (consider that his app is sharing images over the web) IIS was looking for web.config files at every content level on the file server.&lt;/li&gt;

  &lt;li&gt;The problem was there, customer file server was hosting hundreds and hundreds of folders, so the constant work to research web.config files caused the bottleneck.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What was the resolution? We have two possible resolutions here:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;We could configure IIS in order to research webConfig file every 10 minutes for example. To do that we have to set the following registry key as mentioned below: 
    &lt;br /&gt;HKLM\System\CurrentControlSet\Services\W3SVC\Parameters\ConfigPollMilliSeconds = 600000 

    &lt;br /&gt;Further details here: &lt;a href="http://support.microsoft.com/kb/954864"&gt;http://support.microsoft.com/kb/954864 
      &lt;br /&gt;&lt;/a&gt;Of course this setting is not related to a single web application, it has an impact on web server. 

    &lt;br /&gt;This solution could not work for all web applications installed on your IIS, furthermore a new change on your webConfig will be not reflected 

    &lt;br /&gt;immediately.&lt;/li&gt;

  &lt;li&gt;This is my preferred solution, read here: &lt;a href="http://www.iis.net/configreference/system.applicationhost/sites/site/application/virtualdirectory"&gt;http://www.iis.net/configreference/system.applicationhost/sites/site/application/virtualdirectory&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;i&gt;“Optional Boolean attribute. 
      &lt;br /&gt;&lt;/i&gt;&lt;i&gt;Specifies whether IIS looks for Web.config files in content directories lower than the current level (true) or does not look for Web.config files in content directories lower than the current level (false). 
      &lt;br /&gt;&lt;/i&gt;&lt;i&gt;The default value is true.” 
      &lt;br /&gt;&lt;/i&gt;&lt;/p&gt;

  &lt;p&gt;If you change the value of allowSubDirConfig to false in &lt;b&gt;every application’s root&lt;/b&gt;, our goal is achieved: IIS will stop to research for web config file stored on application’s subfolder.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What happened at the end… J IIS7 worked 5 times faster than IIS6 on customer’s environment.&lt;/p&gt;

&lt;p&gt;Thx, 
  &lt;br /&gt;Carmelo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10380973" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term="IIS" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/IIS/" /></entry><entry><title>How to collect a memory dump properly</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2012/12/03/how-to-collect-a-memory-dump-properly.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2012/12/03/how-to-collect-a-memory-dump-properly.aspx</id><published>2012-12-03T14:38:32Z</published><updated>2012-12-03T14:38:32Z</updated><content type="html">&lt;p&gt;After discussing the following topics:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/carmelop/archive/2012/11/03/what-is-a-process-memory-dump.aspx"&gt;What is a process's memory dump&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/carmelop/archive/2012/11/06/first-chance-exception-vs-second-chance-exception.aspx"&gt;First Chance Exception vs Second Chance Exception&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/carmelop/archive/2012/11/13/the-importance-to-collect-a-memory-dump-at-right-time.aspx"&gt;The importance to collect a memory dump at right time&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I believe it is right time to share with you how to collect a process memory dump &lt;b&gt;properly&lt;/b&gt;. Why properly? Because there is not a single way to collect it: you have to act accordingly to your trouble.&lt;/p&gt;  &lt;p&gt;The tool that allows us to collect a memory dumps is called DebugDiag. Please download the x86 version or the x64 version in according with your O.S.'s architecture &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=26798"&gt;http://www.microsoft.com/download/en/details.aspx?id=26798&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Let’s start to analyse our scenarios:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Taking a dump in case&lt;/b&gt;&lt;b&gt; &lt;/b&gt;&lt;b&gt;of&lt;/b&gt;&lt;b&gt; process's crash&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The following rule allows us to collect a memory dump, in case of process's crash. We will not do any assumption on first chance exception, or heap corrupting and so on... We want to take a picture of our process before that it crashes. &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;p&gt;Start DebugDiag. Select crash in the first interface and press the button called “next”:        &lt;br /&gt;&lt;/p&gt;     &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/1754.image_5F00_3BD69A32.png"&gt;&lt;img title="image" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/4401.image_5F00_thumb_5F00_017B2451.png" width="340" height="277" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Select the item called “A specific process”. In case of web app problem, select&amp;#160; “A specific IIS web application pool”      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/8015.clip_5F00_image002_5F00_58FC423C.jpg"&gt;&lt;img title="clip_image002" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image002" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/0184.clip_5F00_image002_5F00_thumb_5F00_0C580599.jpg" width="692" height="308" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/li&gt;    &lt;li&gt;Select process where the issue occurs or write its name with the extension exe. For web app issue, select Application Pool where your web application is working on.      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Configure the last interface as reported below:      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/5543.clip_5F00_image003_5F00_63D92384.jpg"&gt;&lt;img title="clip_image003" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image003" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/7181.clip_5F00_image003_5F00_thumb_5F00_21F23E36.jpg" width="380" height="310" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Create and active the rule.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In case that your process is not crashing but you observe that it closes itself in an unexpected way, please change the step 4 with the following one:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/1727.image_5F00_6796C854.png"&gt;&lt;img title="image" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/6012.image_5F00_thumb_5F00_34971220.png" width="567" height="487" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Basically, we will add a break point on our process as soon as it tries to close itself. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Hang scenarios: my process stops to respond but I do not know why&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;There are situations, where your process does not crash but for some unknown reasons it stops to do its work.    &lt;br /&gt;In these cases, we can collect a dump in the following way:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Start DebugDiag and select the button called cancel in the first interface:      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/1307.clip_5F00_image005_5F00_7FAA0CE2.jpg"&gt;&lt;img title="clip_image005" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image005" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/2783.clip_5F00_image005_5F00_thumb_5F00_3E2F5A89.jpg" width="350" height="307" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/li&gt;    &lt;li&gt;Click on the tab called: “Processes”. DebugDiag shows the list of processes that are running on your machine.&lt;/li&gt;    &lt;li&gt;Right click on the process affected by the issue:      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/6177.clip_5F00_image006_5F00_55E691EF.jpg"&gt;&lt;img title="clip_image006" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image006" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/1307.clip_5F00_image006_5F00_thumb_5F00_146BDF96.jpg" width="428" height="162" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Select the item: “Create Full Userdump”&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In case, that you are troubleshooting an IIS issue, and you are not sure which application pool instance to dump you can have a look at &lt;a href="http://blogs.msdn.com/b/carloc/archive/2007/04/13/find-which-w3wp-exe-instance-is-hosting-your-application.aspx"&gt;http://blogs.msdn.com/b/carloc/archive/2007/04/13/find-which-w3wp-exe-instance-is-hosting-your-application.aspx&lt;/a&gt; to know which process is hosting the blocked application&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Troubleshooting a fist chance exception&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;There are situations, especially working with IIS, where your application does not handle a particular exception. In this situation, it could be expected that hosting process (w3wp for web application) crashes. It is not completely true. I do not want to go in deep about this topic on this post (probably in a new one &lt;img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/6661.wlEmoticon_2D00_smile_5F00_4114996F.png" /&gt; ) but let’s say that IIS is robust enough to handle the exceptions for us.&lt;/p&gt;  &lt;p&gt;In this situation, there is no process's crash so we cannot use the rule mentioned on &amp;quot;&lt;b&gt;Taking a dump in case of process's crash&amp;quot; &lt;/b&gt;section. Technically, we are interested on a fist chance exception or better we are interested to get a dump when a first chance exception come out. How to proceed?     &lt;br /&gt;Follow the steps mentioned on section &amp;quot;&lt;b&gt;Taking a dump in case process's crash&lt;/b&gt;&amp;quot; but change the step 4 with this one:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/5008.clip_5F00_image007_5F00_4BD1F0C4.jpg"&gt;&lt;img title="clip_image007" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image007" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/4186.clip_5F00_image007_5F00_thumb_5F00_05748AAF.jpg" width="687" height="452" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Performance issues&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;This rule is valid only for &lt;b&gt;web applications&lt;/b&gt; and we should use it in case that our web application is working in a slow way.&lt;/p&gt;  &lt;p&gt;For example, typically a specific page MyPage.aspx answers in 5 seconds to final users. Sometimes, without having network issue, the same page is shown back to final users in 30 - 60 seconds. What it is going on! A dump will help us:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;p&gt;Run debugDiag and select the item: Performance        &lt;br /&gt;&lt;/p&gt;     &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/1460.clip_5F00_image008_5F00_03C3BEDB.jpg"&gt;&lt;img title="clip_image008" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image008" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/8304.clip_5F00_image008_5F00_thumb_5F00_6D217093.jpg" width="394" height="319" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt; After that, please select the item: HTTP Response Time. &amp;gt; Add UR&lt;/li&gt;    &lt;li&gt;DebugDiag will show the following interface:      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/4812.clip_5F00_image009_5F00_04D8A7FA.jpg"&gt;&lt;img title="clip_image009" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image009" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/2746.clip_5F00_image009_5F00_thumb_5F00_1F389B11.jpg" width="444" height="376" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;Set timeout to 30 seconds (or a proper value) and press O&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;Press next and “Add dump target”&lt;/li&gt;    &lt;li&gt;Please select application pool affected by the issue.&lt;/li&gt;    &lt;li&gt;Configure the last interface as showed below:&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/3482.clip_5F00_image010_5F00_09027FBF.jpg"&gt;&lt;img title="clip_image010" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="clip_image010" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-25-98-metablogapi/6138.clip_5F00_image010_5F00_thumb_5F00_0751B3EB.jpg" width="455" height="370" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Hope this help,    &lt;br /&gt;Carmelo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10374075" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term="dump" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/dump/" /></entry><entry><title>The importance to collect a memory dump at right time</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/carmelop/archive/2012/11/13/the-importance-to-collect-a-memory-dump-at-right-time.aspx" /><id>http://blogs.msdn.com/b/carmelop/archive/2012/11/13/the-importance-to-collect-a-memory-dump-at-right-time.aspx</id><published>2012-11-13T18:05:00Z</published><updated>2012-11-13T18:05:00Z</updated><content type="html">&lt;p&gt;Collect a memory dump (in some scenarios) is the only way to understand what it is going wrong inside your process. Why? Since you have the possibility to check your application from inside.&lt;/p&gt;  &lt;p&gt;As I wrote &lt;a href="http://blogs.msdn.com/b/carmelop/archive/2012/11/03/what-is-a-process-memory-dump.aspx"&gt;here&lt;/a&gt;, a memory dump is a &amp;quot;picture&amp;quot; of your application for a specific moment of its life. So, it is particularly relevant for me to share with you &lt;strong&gt;why it is important to collect a memory dump at right time&lt;/strong&gt;. To understand it, let me share with you the following example. It is a game that should better explain the topic of this post:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We have four people and three chairs. As soon as a specific condition occurs, the four people have to sit in one of the available chairs at the same time. As you can understand, it is expected that one person has not the possibility to find his sit.&lt;/li&gt;    &lt;li&gt;The game's goal is to understand what person is not able to take his chair. The only possibility to active this goal is to take a picture of the room where our people are gaming on.&lt;/li&gt;    &lt;li&gt;How can you active this goal? It is easy, you have to take a picture of our room game &lt;strong&gt;as soon as all 3 chairs are occupied by our players&lt;/strong&gt;. In that moment &lt;strong&gt;and exactly in that moment&lt;/strong&gt;, you will be able to understand what person was not able to find his sit.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Taking a picture in a different moment, &lt;strong&gt;will not allow you to achieve your goal&lt;/strong&gt;. You can do some suppositions, but the only way to be 100% sure about your answer is that: take a picture when all chairs are occupied.&lt;/p&gt;  &lt;p&gt;This example should explain the importance to collect a picture, so a memory dump, at right time. Consider for example that you are troubleshooting a first chance exception for your application. Taking a memory dump after two or three minutes that exception occurred is not a good action to understand what is going on. Why? Since the process moved its internal state to a different point, so inside the dump you can see threads not at relevant moment.&lt;/p&gt;  &lt;p&gt;You can consider threads as our game players: taking a picture of them in a wrong moment do not allow you to understand where the issue is!&lt;/p&gt;  &lt;p&gt;So be sure to collect a dump properly, according to the issue you are trying to figure out.&lt;/p&gt;  &lt;p&gt;Thx,&lt;/p&gt;  &lt;p&gt;Carmelo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10368135" width="1" height="1"&gt;</content><author><name>pulvirenti.carmelo</name><uri>http://blogs.msdn.com/pulvirenti.carmelo/ProfileUrlRedirect.ashx</uri></author><category term="dump" scheme="http://blogs.msdn.com/b/carmelop/archive/tags/dump/" /></entry></feed>