<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-7041745156199549192</id><updated>2009-11-09T02:20:42.957-08:00</updated><title type='text'>Filip's Technical Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default?start-index=26&amp;max-results=25'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>53</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-6561712649580913018</id><published>2009-10-30T04:34:00.000-07:00</published><updated>2009-11-02T01:50:58.851-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>Asp.Net: Validating data type using CompareValidator</title><content type='html'>CompareValidator, as the name says, is mainly used to compare value of specified control against value of another control, constant, etc. You can specify the operator that can be used in comparison so you are not limited to checking equality. The following example demonstrates simple comparison of int values (max &amp;gt; min):&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&lt;br /&gt;Min: &amp;lt;asp:TextBox ID="TextBox1" runat="server"/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;Max: &amp;lt;asp:TextBox ID="TextBox2" runat="server"/&amp;gt;&lt;br /&gt;     &amp;lt;asp:CompareValidator&lt;br /&gt;            ID="CompareValidator1"&lt;br /&gt;            runat="server" &lt;br /&gt;            ControlToCompare="TextBox1"&lt;br /&gt;            ControlToValidate="TextBox2" &lt;br /&gt;            ErrorMessage="Max must be greater than Min"&lt;br /&gt;            Operator="GreaterThan" &lt;br /&gt;            Type="Integer"&amp;gt;&lt;br /&gt;     &amp;lt;/asp:CompareValidator&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;     &amp;lt;asp:Button ID="Button1" runat="server" Text="Submit" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Which results in:&lt;br /&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;width: 392px; height: 86px;" src="http://4.bp.blogspot.com/_7so4C0dWMLE/Su6mQCZz5rI/AAAAAAAAAMQ/45Kij_SWo1Y/s400/comp1.png" border="0" alt="Results of comparison against different control" id="BLOGGER_PHOTO_ID_5399435797717051058" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: 120%"&gt;&lt;b&gt;Validating data type&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Except the basic functionality CompareValidator supports validation of data types. Except the regular operators (Equal, GreaterThan, GreaterThanEqual, LessThan &amp; LessThanEqual) CompareValidator supports an additional one called &lt;span style="font-style:italic;"&gt;&lt;span style="font-weight:bold;"&gt;"DataTypeCheck"&lt;/span&gt;&lt;/span&gt;. It can be used to validate the type of provided value against the type specified in validator. The supported types are: String, Integer, Double, Currency &amp; Date. The validator mainly checks the format of the provided value. In case of Date type it also checks the range (e.g. to ensure that 31st of April is not valid). I like this feature, especially that I've already seen a quite complex custom validator written to do exact this task. Example:&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&lt;br /&gt;Date: &amp;lt;asp:TextBox ID="TextBox1" runat="server" /&amp;gt;&lt;br /&gt;      &amp;lt;asp:CompareValidator &lt;br /&gt;               ID="CompareValidator1"&lt;br /&gt;               runat="server"&lt;br /&gt;               ControlToValidate="TextBox1"&lt;br /&gt;               ErrorMessage="Invalid date"&lt;br /&gt;               Type="Date"&lt;br /&gt;               Operator="DataTypeCheck"/&amp;gt;&lt;br /&gt;      &amp;lt;asp:Button runat="server" Text="Submit"/&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Which results in:&lt;img style="display:block; margin:0px auto 10px; text-align:center;width: 287px; height: 64px;" src="http://2.bp.blogspot.com/_7so4C0dWMLE/Su6mQDGhkOI/AAAAAAAAAMY/b9CJzfMKCWk/s400/comp2.PNG" border="0" alt="Invalid date provided" id="BLOGGER_PHOTO_ID_5399435797904593122" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: 120%"&gt;&lt;b&gt;Using right format&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;When validating the type Asp.Net uses the current Page Culture. If you'd like only to accept inputs in specified format you can set the Page Culture property manually. The same date "11.30.2009" will be validated differently for UK and US Cultures (in UK "DD.MM.YYYY" is used, in US it's "MM.DD.YYYY"):&lt;br /&gt;&lt;br /&gt;UK:&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&amp;lt;%@ Page ... Culture="en-GB"%&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;width: 287px; height: 64px;" src="http://1.bp.blogspot.com/_7so4C0dWMLE/Su6mQdWL1BI/AAAAAAAAAMg/LCORdzNo12M/s400/en-uk.PNG" border="0" alt="Date invalid for Culture en-GB" id="BLOGGER_PHOTO_ID_5399435804949599250" /&gt;&lt;br /&gt;&lt;br /&gt;US:&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&amp;lt;%@ Page ... Culture="en-US"%&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:width: 202px; height: 64px;" src="http://1.bp.blogspot.com/_7so4C0dWMLE/Su6mQmtqaBI/AAAAAAAAAMo/Ov-WudZZc6Y/s400/en-us.PNG" border="0" alt="Date valid for Culture en-US" id="BLOGGER_PHOTO_ID_5399435807463991314" /&gt;&lt;br /&gt;&lt;br /&gt;You can also set the page Culture from your code by overriding InitializeCulture() method:&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;&lt;br /&gt;protected override void InitializeCulture()&lt;br /&gt;{&lt;br /&gt;    Culture = "en-US";&lt;br /&gt;    Thread.CurrentThread.CurrentCulture =&lt;br /&gt;                     CultureInfo.CreateSpecificCulture("en-US");            &lt;br /&gt;            &lt;br /&gt;    base.InitializeCulture();&lt;br /&gt;}&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-6561712649580913018?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/6561712649580913018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=6561712649580913018' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/6561712649580913018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/6561712649580913018'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/10/aspnet-validating-data-type-using.html' title='Asp.Net: Validating data type using CompareValidator'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_7so4C0dWMLE/Su6mQCZz5rI/AAAAAAAAAMQ/45Kij_SWo1Y/s72-c/comp1.png' height='72' width='72'/><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-6633857978570137872</id><published>2009-10-19T05:14:00.001-07:00</published><updated>2009-10-19T05:42:30.816-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><title type='text'>The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM</title><content type='html'>I've deployed a WCF service to IIS with security mode set to "Message":&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&lt;binding ... &gt;&lt;br /&gt;   &lt;security mode="Message"&gt;&lt;br /&gt;      &lt;message ... /&gt;&lt;br /&gt;   &lt;/security&gt;&lt;br /&gt;&lt;/binding&gt;&lt;/pre&gt;&lt;br /&gt;When I tried to called it from my client app I got the following error:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I googled out that this is caused by security settings of the service virtual directory. I configured it to use Integrated Windows Authentication rather than allowing Anonymous access. I did so because I wanted to restrict the access to my service.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;It came out that using Anonymous Access in this particular case (WCF service in Message security mode) doesn't mean that anyone is allowed to use the service. The authentication is performed by WCF rather than IIS, but it still takes place. &lt;br /&gt;&lt;br /&gt;Answer found &lt;a href="http://social.msdn.microsoft.com/forums/en-US/wcf/thread/267a5412-7e2e-48d0-b628-5039cd07e6e1/" target="_blank" title="Why to use Anonymous Access for WCF services in Message security mode"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-6633857978570137872?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/6633857978570137872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=6633857978570137872' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/6633857978570137872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/6633857978570137872'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/10/http-request-is-unauthorized-with.html' title='The HTTP request is unauthorized with client authentication scheme &apos;Anonymous&apos;. The authentication header received from the server was &apos;Negotiate,NTLM'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-525215325022427776</id><published>2009-07-28T02:43:00.000-07:00</published><updated>2009-08-02T02:39:20.553-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>ASP.NET: How to trigger the client-side validation manually</title><content type='html'>By default the client-side validation is triggered when submitting forms using buttons. However, sometimes you may want to trigger client-side validation on your ASP page manually from custom Javascript. You can achieve that by calling Javascript validation functions provided by the ASP.Net framework directly from your custom code.&lt;br /&gt;&lt;br /&gt;The following page source example displays a &lt;code&gt;TextBox&lt;/code&gt; and its validation controls (&lt;code&gt;RequiredFieldValidator &amp; ValidationSummary&lt;/code&gt;). The validation controls have the same &lt;code&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basevalidator.validationgroup.aspx" title="ValidationGroup property info by MSDN" target="_blank"&gt;ValidationGroup&lt;/a&gt;&lt;/code&gt; defined, which allows us to validate different page elements independently. The page displays also a &lt;code&gt;DIV&lt;/code&gt; element that will cause the Validation action when clicked:&lt;pre class="brush: html;"&gt;&amp;lt;!-- Validation Summary --&amp;gt;&lt;br /&gt;&amp;lt;asp:ValidationSummary ID="ValidationSummary1" runat="server"&lt;br /&gt;            HeaderText="Validation errors:" ValidationGroup="Group1"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- TextBox and its validator --&amp;gt;&lt;br /&gt;Name: &amp;lt;asp:TextBox ID="TextBox1" runat="server" /&amp;gt;&lt;br /&gt;&amp;lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" &lt;br /&gt;            ErrorMessage="Name is required" Text="*"&lt;br /&gt;            ControlToValidate="TextBox1" ValidationGroup="Group1"&amp;gt; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- Div that causes client-side validation when clicked --&amp;gt;&lt;br /&gt;&amp;lt;div onclick="Validate();" &amp;gt;Validate Form&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;br /&gt;The code above should should produce smth like that when validation is triggered:&lt;br /&gt;&lt;br /&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 236px; height: 118px;" src="http://1.bp.blogspot.com/_7so4C0dWMLE/SnTK_eIhS9I/AAAAAAAAALo/100oGVpI-Is/s400/validation.GIF" border="0" alt="Validation form" id="BLOGGER_PHOTO_ID_5365136247874472914" /&gt;&lt;br /&gt;Now let's take a look at the custom JS code that triggers the validation. There are couple ways to do that:&lt;ul&gt;&lt;li&gt;Easy way - works for all validators from the same ValidationGroup:&lt;pre class="brush: js;"&gt;function Validate()&lt;br /&gt;{&lt;br /&gt;    // If no group name provided the whole page gets validated&lt;br /&gt;    Page_ClientValidate('Group1');&lt;br /&gt;}&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;If you want to validate only specific validators:&lt;pre class="brush: js;"&gt;function Validate()&lt;br /&gt;{&lt;br /&gt;    // Get the specific validator element&lt;br /&gt;    var validator = document.getElementById('RequiredFieldValidator1');&lt;br /&gt;&lt;br /&gt;    // Validate chosen validator&lt;br /&gt;    ValidatorValidate(validator);&lt;br /&gt;&lt;br /&gt;    // Update validation summary for chosen validation group&lt;br /&gt;    ValidatorUpdateIsValid();&lt;br /&gt;    ValidationSummaryOnSubmit(validationGroup);    &lt;br /&gt;}&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Useful links:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa479045.aspx" title="ASP.NET Validation in Depth" target="_blank"&gt;ASP.NET Validation in Depth (by MSDN)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2008/05/14/how-to-manage-asp.net-validation-from-javascript-with-jquery.aspx" title="Example on how to manage validation with jQuery" target="_blank"&gt;Example on how to manage validation with jQuery&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-525215325022427776?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/525215325022427776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=525215325022427776' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/525215325022427776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/525215325022427776'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/07/aspnet-how-to-trigger-client-side.html' title='ASP.NET: How to trigger the client-side validation manually'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_7so4C0dWMLE/SnTK_eIhS9I/AAAAAAAAALo/100oGVpI-Is/s72-c/validation.GIF' height='72' width='72'/><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-8370287422428958003</id><published>2009-07-03T04:00:00.000-07:00</published><updated>2009-07-15T01:59:26.704-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# - Array to Dictionary</title><content type='html'>Recently I needed to convert an Array of &lt;code&gt;DictionaryEntry&amp;lt;object,object&amp;gt;&lt;/code&gt; items into a &lt;code&gt;Dictionary&amp;lt;string,string&amp;gt;&lt;/code&gt; object. Here is simple code using &lt;a href="http://msdn.microsoft.com/en-us/netframework/aa904594.aspx" target="_blank" title="Language Integrated Query"&gt;LINQ&lt;/a&gt; and &lt;code&gt;ToDictionary&lt;/code&gt; method for doing that with 1 command:&lt;pre class="brush: csharp;"&gt;DictionaryEntry&amp;lt;object,object&amp;gt;[] props = GetSomeProperties();&lt;br /&gt;Dictionary&amp;lt;string,string&amp;gt; dict = &lt;br /&gt;   props.ToDictionary(de =&gt; (de.Key != null)   ? de.Key.ToString() :&lt;br /&gt;                                                 string.Empty);&lt;br /&gt;                      de =&gt; (de.Value != null) ? de.Value.ToString() :&lt;br /&gt;                                                 string.Empty);&lt;/pre&gt;&lt;br /&gt;Isn't that simple? :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-8370287422428958003?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/8370287422428958003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=8370287422428958003' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8370287422428958003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8370287422428958003'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/07/c-array-to-dictionary.html' title='C# - Array to Dictionary'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-7790222850725959006</id><published>2009-06-26T03:05:00.001-07:00</published><updated>2009-10-08T05:26:34.363-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><title type='text'>Windows could not start the IIS Admin Service on Local Computer</title><content type='html'>Sometime when starting IIS I'm getting the following error:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Windows could not start the IIS Admin Service on Local Computer. For more information, review the System Event Log. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code -2147417831.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Event log is not much help:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;The IIS Admin Service service terminated with service-specific error 2147549465 (0x80010119).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;Kill the inetinfo.exe process and start IIS again - that's it :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-7790222850725959006?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/7790222850725959006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=7790222850725959006' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7790222850725959006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7790222850725959006'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/06/windows-could-not-start-iis-admin.html' title='Windows could not start the IIS Admin Service on Local Computer'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-8633773301194274495</id><published>2009-06-18T04:16:00.001-07:00</published><updated>2009-07-14T14:26:36.526-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>Handling exceptions from multiple UpdatePanels</title><content type='html'>In one of my previous posts I've already mentioned how to handle exceptions that occur within UpdatePanel on client side (&lt;a href="http://fczaja.blogspot.com/2009/02/handle-exception-in-updatepanel.html" target="_blank" title="Handling exceptions in UpdatePanel &amp; UpdatePanelAnimationExtender"&gt;see post&lt;/a&gt;). However, this did not cover server side error handling nor multiple UpdatePanels on one page.&lt;br /&gt;&lt;br /&gt;Sometimes you may want to have on your ASP page multiple update panels or a large one containing multiple controls. The problem is that when an error occurs on update action you may find hard to localize the actual control that generated the error causing event. This may be required in some situations e.g. to display error message next to the control responsible for the exception.&lt;br /&gt;&lt;br /&gt;Let's take a look at some code. Here is a sample ASP page with a ScriptManager and 2 UpdatePanels. Each of the panels contains a button and a label for displaying errors:&lt;pre class="brush: xml;"&gt;&amp;lt;asp:ScriptManager ID="ScriptManager1" runat="server" &lt;br /&gt;            onasyncpostbackerror="ScriptManager1_AsyncPostBackError"&amp;gt;&lt;br /&gt;&amp;lt;/asp:ScriptManager&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- First Update Panel --&amp;gt;&lt;br /&gt;&amp;lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&amp;gt;&lt;br /&gt; &amp;lt;ContentTemplate&amp;gt;&lt;br /&gt;  &amp;lt;asp:Button ID="B1" runat="server" Text="B1" onclick="B1_Click" /&amp;gt;&lt;br /&gt;  &amp;lt;asp:Label ID="Label1" runat="server"&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt; &amp;lt;/ContentTemplate&amp;gt;&lt;br /&gt;&amp;lt;/asp:UpdatePanel&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- Second Update Panel --&amp;gt;&lt;br /&gt;&amp;lt;asp:UpdatePanel ID="UpdatePanel2" runat="server"&amp;gt;&lt;br /&gt; &amp;lt;ContentTemplate&amp;gt;&lt;br /&gt;  &amp;lt;asp:Button ID="B2" runat="server" Text="B2" onclick="B2_Click" /&amp;gt;&lt;br /&gt;  &amp;lt;asp:Label ID="Label2" runat="server"&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt; &amp;lt;/ContentTemplate&amp;gt;&lt;br /&gt;&amp;lt;/asp:UpdatePanel&amp;gt;&lt;/pre&gt;As you can see the ScriptManager has an error handler defined (line 2) and both buttons have click handlers assigned. The error labels are empty on entry.&lt;br /&gt;Here is Code Behind for that page:&lt;pre class="brush: csharp;"&gt;  protected void B1_Click(object sender, EventArgs e)&lt;br /&gt;  {&lt;br /&gt;    throw new Exception("Exception from Button1");&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  protected void B2_Click(object sender, EventArgs e)&lt;br /&gt;  {&lt;br /&gt;    throw new Exception("Exception from Button2");&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  protected void ScriptManager1_AsyncPostBackError(&lt;br /&gt;                      object sender, AsyncPostBackErrorEventArgs e)&lt;br /&gt;  {&lt;br /&gt;    // Do smth with the error e.g log it&lt;br /&gt;  }&lt;/pre&gt;Clicking on any of the buttons will cause an Exception. The exception message varies for each button. In my example the error handler for script manager does nothing but you can do whatever you need with the caught error e.g. log it.&lt;br /&gt;&lt;br /&gt;Now, let's handle the error on client side. The following code will register client side error handler, which will display a message from the thrown exception next to appropriate button:&lt;pre class="brush: js;"&gt;// Register EndRequest handler for ScriptManager&lt;br /&gt;  Sys.WebForms.PageRequestManager.getInstance().&lt;br /&gt;                                    add_endRequest(EndRequestHandler);&lt;br /&gt;&lt;br /&gt;  function EndRequestHandler(sender, args)&lt;br /&gt;  {&lt;br /&gt;    // If there is an unhandled error&lt;br /&gt;    if (args.get_error() != undefined)&lt;br /&gt;    {&lt;br /&gt;      // Get id of the control that fired the error-causing action&lt;br /&gt;      var senderControlId = sender._postBackSettings.sourceElement.id;&lt;br /&gt;            &lt;br /&gt;      // Get Label next to the source control&lt;br /&gt;      var errorLabel = document.getElementById(senderControlId).&lt;br /&gt;                                              nextSibling.nextSibling;&lt;br /&gt;            &lt;br /&gt;      // Set error message in appropriate control.&lt;br /&gt;      // You may want to remove the user-unfriendly part of the&lt;br /&gt;      // message that was added by Script Manager&lt;br /&gt;      errorLabel.innerHTML = &lt;br /&gt;        args.get_error().message.replace&lt;br /&gt;        ('Sys.WebForms.PageRequestManagerServerErrorException: ', '');&lt;br /&gt;&lt;br /&gt;      // Mark the error as handled&lt;br /&gt;      args.set_errorHandled(true);&lt;br /&gt;    }&lt;br /&gt;  }&lt;/pre&gt;&lt;br /&gt;That's it. To make it work just place the JS code on your ASP page.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-8633773301194274495?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/8633773301194274495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=8633773301194274495' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8633773301194274495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8633773301194274495'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/06/handling-exceptions-from-multiple.html' title='Handling exceptions from multiple UpdatePanels'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-916483034433450372</id><published>2009-06-11T05:28:00.000-07:00</published><updated>2009-07-08T11:34:27.094-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Centering Adsense Ads on blogger pages</title><content type='html'>Recently I decided to add &lt;a href="https://www.google.com/adsense/" target="_blank"&gt;Adsense&lt;/a&gt; ads on my blogger page to earn zillions of $$$$. Blogger dashboard offers easy to use Adsense integration (Monetize tab). It helps you to create Adsense account and automatically places the ads on your blog page. The problem is that it doesn't offer much control over the way the ads are displayed, soe you can't e.g. center your ad, align it in to the right etc. To achieve that you'll need to create the ad manually through the Adsense page (see &lt;a href="https://www.google.com/adsense/support/?sourceid=aso&amp;subid=ww-ww-et-asui&amp;medium=link" target="_blank"&gt;Adsense help&lt;/a&gt;) and then paste the code into your blogger template:&lt;ol&gt;&lt;li&gt;From blogger dashboard got to: &lt;span style="font-weight:bold;"&gt;&amp;nbsp;Layout &gt; Edit Html&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Check the "Expand Widget Templates" checkbox to see the detailed view of your template&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Find the place in the template where you'd like to place the ad.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;code&gt;&lt;b&gt;div&lt;/b&gt;&lt;/code&gt; element that would store your ad and style it as much as you want (center it, add padding, etc.)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Paste the code generated by Adsense into the &lt;code&gt;&lt;b&gt;div&lt;/b&gt;&lt;/code&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the following characters in the generated Adsense code:&lt;ul&gt;&lt;br /&gt;&lt;li&gt;   &lt;b&gt;&amp;lt;&lt;/b&gt;   change to   &lt;b&gt;&amp;amp;lt;&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;   &lt;b&gt;&amp;gt;&lt;/b&gt;   change to   &lt;b&gt;&amp;amp;lt;&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;   &lt;b&gt;&amp;quot;&lt;/b&gt;   change to   &lt;b&gt;&amp;amp;quot;&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;so the code for your Ad looks somehow like this (changed lines: 1, 2, 3, 5 &amp; 8):&lt;pre class="brush: js; auto-links: false;"&gt;&amp;lt;script type='text/javascript'&amp;gt;&amp;amp;lt;!--&lt;br /&gt;google_ad_client = &amp;amp;quot;pub-5***************&amp;amp;quot;;&lt;br /&gt;google_ad_host = &amp;amp;quot;pub-1***************&amp;amp;quot;;&lt;br /&gt;/* name of your ad */&lt;br /&gt;google_ad_slot = &amp;amp;quot;7*********&amp;amp;quot;;&lt;br /&gt;google_ad_width = 160;&lt;br /&gt;google_ad_height = 600;&lt;br /&gt;//--&amp;amp;gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src='http://some_google_linkto_js_file'&lt;br /&gt;        type='text/javascript'&amp;gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/pre&gt;It is &lt;b&gt;important&lt;/b&gt; that you do this, otherwise you'll get a JS error '&lt;span style="font-weight:bold; font-style:italic;"&gt;pub is undefined&lt;/span&gt;' (or something similar) on the page and the ad will not be displayed.&lt;/li&gt;&lt;/ol&gt;Solution and automatic converter found  &lt;a href="http://www.hacktrix.com/adsense-code-converter-for-blogger-blogs" target="_blank"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-916483034433450372?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/916483034433450372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=916483034433450372' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/916483034433450372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/916483034433450372'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/06/centering-adsense-ads-on-blogger-pages.html' title='Centering Adsense Ads on blogger pages'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-8268883112009687541</id><published>2009-05-29T03:12:00.001-07:00</published><updated>2009-06-16T13:46:36.383-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><title type='text'>JS: Display tooltip over page element</title><content type='html'>To display a tooltip over a page element:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create hidden tooltip element:&lt;br /&gt;&lt;pre class="brush: js;"&gt;&lt;div id="tooltip" style="position: absolute; display: none"&gt;&lt;br /&gt;   Some tooltip info&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Create JS scripts for showing/hiding tooltip:&lt;br /&gt;&lt;pre class="brush: js;"&gt;function show()&lt;br /&gt;{&lt;br /&gt;var tooltip = document.getElementById('tooltip');&lt;br /&gt;tooltip.style.top = event.clientY;&lt;br /&gt;tooltip.style.left = event.clientX + 10;&lt;br /&gt;tooltip.style.display = 'block';&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function hide(){&lt;br /&gt;var tooltip = document.getElementById('tooltip');&lt;br /&gt;tooltip.style.display = 'none';&lt;br /&gt;}&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Set Javascript events for the chosen page element:&lt;br /&gt;&lt;pre class="brush: html;"&gt;&lt;div onmouseover="show();" onmouseout="hide();"&gt;&lt;br /&gt;   Element content&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;Tested on IE7.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-8268883112009687541?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/8268883112009687541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=8268883112009687541' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8268883112009687541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8268883112009687541'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/05/js-display-tooltip-over-page-element.html' title='JS: Display tooltip over page element'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-7333155134445331494</id><published>2009-05-04T08:08:00.000-07:00</published><updated>2009-06-16T13:46:04.358-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.</title><content type='html'>A piece of code that I've been working on lately started to throw exceptions when calling a web service using a generated client. The logg file contained only the exception message:&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;span style="font-style:italic;"&gt;"The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state."&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Most of the suggestions found in Web blamed the invalid code, giving examples similar to the following one:&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;&lt;br /&gt;using (MyWebServiceClient service = new MyWegServiceClient())&lt;br /&gt;{&lt;br /&gt;   service.DoSomeOperation();&lt;br /&gt;   service.Close();&lt;br /&gt;   service.DoAnotherOperation();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Since I was sure this was not the case I had to discover the real exception reason by myself.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;After debugging the app it came out that solution was quite simple - the service configuration (URL, security settings) was invalid. I found that out by analyzing the InnerException of the main Exception. The logged exception message was rather irrelevant to the actuall error.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-7333155134445331494?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/7333155134445331494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=7333155134445331494' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7333155134445331494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7333155134445331494'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/05/communication-object.html' title='The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-4423959789219174052</id><published>2009-04-14T02:51:00.000-07:00</published><updated>2009-04-14T03:04:41.315-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Join the Java Black Belt community</title><content type='html'>I'm recently working mainly on .NET projects but would like to stay on top of Java technology stack as well. That's why I've just joined the &lt;a href="http://www.javablackbelt.com" target="_blank"&gt;Java Black Belt&lt;/a&gt; community.&lt;br /&gt;It offers many free java exams created by community users. In order to get the black belt you need to contribute to the portal so the amount of testing material is still growing. &lt;br /&gt;It's a great way to refresh your java knowledge. I hope that this belt-system will keep me motivated so I not only prove my current skills but also learn something new. &lt;br /&gt;After I get to the certain level (let's say the blue belt) I'll update my blogger profile to display the belt icon so you can see my progress directly from this page.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-4423959789219174052?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/4423959789219174052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=4423959789219174052' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/4423959789219174052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/4423959789219174052'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/04/join-java-black-belt-community.html' title='Join the Java Black Belt community'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-7816709634701672991</id><published>2009-03-24T03:05:00.000-07:00</published><updated>2009-03-24T03:40:38.633-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Debugging .NET applications</title><content type='html'>Recently I attended &lt;a href="http://c2c.org.pl/" target="_blank"&gt;C2C conference&lt;/a&gt; in Warsaw. I signed up for the .NET track. The session I was really looking forward to was “Hardcore Production Debugging” by Ingo Rammer. I hoped to learn something that I could use right away in my every day work. Remote debugging may be very painful and it is not easy to find the best approach. I was keen to learn about new easy-to-use tools that would make my life much easier. Unfortunately, the word “Hardcore” in session’s title was there for a reason…&lt;br /&gt;&lt;br /&gt;The biggest part of the session was dedicated to WinDBG tool. Its interface is very poor and user-unfriendly. However, Ingo demonstrated that once you learn how to use it, it can be very helpful in finding the reason for application failures.&lt;br /&gt;&lt;br /&gt;At first Ingo simulated situation where the developer has access to production machine (with no Visual Studio installed) where they can run WinDBG. Once he started this tool he attached it to the process of sample application that was throwing unhandled exceptions. With a few commands he was able to find out the exception message and the reason for failure. With the same tool Ingo was able to find out the reason for unexpected application exit by attaching breakpoint at the end of app’s process.&lt;br /&gt;&lt;br /&gt;Ingo showed us also that remote debugging can be achieved with the WinDBG installed on developers machine and its console version – CDB – on client’s machine. After you configure the port for CDB you can access it from outside using WinDBG (option “Connect to remote session”).&lt;br /&gt;&lt;br /&gt;Next, Ingo explained what to do when WinDBG and CDB are also not available on the production machine. He proved that we can find the same error as in the first part by studying the memory dump created for that application. To get the memory dump we can ask the client to create it manually using a simple program (Adplus) or OS built-in functionality (only on Vista) immediately after the error occurs. Then, all we need to do is load the dump into WinDBG (option “Open crush dump”) on the developer’s machine and examine it using the same commands as in the first case. &lt;br /&gt;&lt;br /&gt;Finally, Ingo presented simple program GFlags for Windows registry keys modifications that would allow launching CMD/WinDBG immediately after specified process is started and attaching the debugger to this process. This can be handy when an error does not occur regularly and it’s not easy to reproduce. He warned us that you have to be very careful when using that tool and change system’s default settings only if you’re absolutely sure what you’re doing. Registry modifications can cause a lot of damage to your OS if the are not done correctly.&lt;br /&gt;&lt;br /&gt;To sum up - the pase of presentation was high so it was not possible to learn all the commands that Ingo was using. The goal of this session was to show to the audience what is possible if we use the presented tools and that it doesn't require much work once you learn how to use them. &lt;br /&gt;&lt;br /&gt;The session itself came out to be the highlight of the conference. Mixture of Ingo’s knowledge and charm proved to be the formula for perfect presentation. I just wish Ingo had some more time so we could study the examples more carefully. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Some WinDBG commands used by Ingo:&lt;/span&gt;&lt;br /&gt;&lt;pre class="brush: bash; toolbar: false; gutter: false"&gt;&lt;br /&gt;.hh         Debugger Help&lt;br /&gt;sxe clr     Break on all CLR Exceptions&lt;br /&gt;sxi clr     Ignore CLR Exceptions&lt;br /&gt;sxn clr     Notify on CLR Exception&lt;br /&gt; &lt;br /&gt;.loadby sos mscorwks   &lt;br /&gt;            Loads SOS Debugging Extension; &lt;br /&gt;            Enables use of following options:&lt;br /&gt;&lt;br /&gt;  !help            &lt;br /&gt;  !printexception (!pe)&lt;br /&gt;  !clrstack&lt;br /&gt;  &lt;br /&gt;  ~            list threads&lt;br /&gt;  !threads     list managed code threads&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Some Useful links:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx" target="_blank"&gt;All presented debugg tools for Windows &lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.thinktecture.com/staff/ingo" target="_blank"&gt;Ingo's page at Thinktecture&lt;/a&gt;&lt;br /&gt;Tess Fernandez blog &lt;a href="http://blogs.msdn.com/tess/" target="_blank"&gt;“If broken it is, fix it you should”&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Ingo also recommended book "Debugging .NET" by John Robins.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-7816709634701672991?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/7816709634701672991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=7816709634701672991' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7816709634701672991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7816709634701672991'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/03/recently-i-attended-c2c-conference-in.html' title='Debugging .NET applications'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-8826692979894926586</id><published>2009-03-04T05:01:00.000-08:00</published><updated>2009-03-04T13:02:14.249-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Syntax highlighter toolbar covers first code line</title><content type='html'>As mentioned in my &lt;a href="http://fczaja.blogspot.com/2009/03/code-snippets-on-blogger.html"&gt;previous post&lt;/a&gt; I'm using &lt;a href="http://alexgorbatchev.com/wiki/SyntaxHighlighter" target="_blank"&gt;Syntax Highlighter&lt;/a&gt; now to display code snippets. Appart slow loading it's working fine and it's doing its job. The only thing that was annoying to me was that the highlighter's toolbar was covering part of the first code line if it was too long:&lt;br /&gt;&lt;br /&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 49px;" src="http://1.bp.blogspot.com/_7so4C0dWMLE/Sa7ofCq86DI/AAAAAAAAAFk/TE0y5fAJdcQ/s400/old.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5309436630707005490" /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;Solution is quite simple: I decided to lift it up a bit by overwritting toolbar's style:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: css;"&gt;&lt;style&gt;&lt;br /&gt;.syntaxhighlighter .toolbar &lt;br /&gt;{&lt;br /&gt;   top: -33px !important;&lt;br /&gt;}&lt;br /&gt;&lt;/style&gt;&lt;/pre&gt;Place this style definition anywhere in &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; and the result should be similar to that:&lt;br /&gt;&lt;br /&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 60px;" src="http://2.bp.blogspot.com/_7so4C0dWMLE/Sa7qmzuulCI/AAAAAAAAAFs/hiKEndDV9b0/s400/new.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5309438963158520866" /&gt;To be honest, I would like the toolbar to be displayed below the code snippet, aligned to the bottom border but this would require bit more styling. Let me know if you achieve that!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-8826692979894926586?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/8826692979894926586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=8826692979894926586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8826692979894926586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8826692979894926586'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/03/syntax-highlighter-toolbar-covers-first.html' title='Syntax highlighter toolbar covers first code line'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_7so4C0dWMLE/Sa7ofCq86DI/AAAAAAAAAFk/TE0y5fAJdcQ/s72-c/old.PNG' height='72' width='72'/><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-4731178553113681354</id><published>2009-03-02T03:12:00.001-08:00</published><updated>2009-03-04T13:03:15.683-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Code snippets on blogger</title><content type='html'>I decided to adjust the way I display code snippets on my blog. The old way of displaying wasn't very good and required some additional formatting. I've found a perfect solution for that: &lt;a href="http://alexgorbatchev.com/wiki/SyntaxHighlighter" target="_blank"&gt;Syntax Highlighter&lt;/a&gt;. This allows you to easily display code snippets in a nice and accessible way. The code is colorised according to its type: e.g.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Xml:&lt;/span&gt;&lt;pre class="brush: xml;"&gt;&lt;br /&gt;&lt;root&gt;&lt;br /&gt;  &lt;child id="child1"&gt;sample&lt;/child&gt;&lt;br /&gt;&lt;/root&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-weight:bold;"&gt;Java:&lt;/span&gt;&lt;pre class="brush: java; bloggerMode: true;"&gt;class HelloWorld&lt;br /&gt;{  &lt;br /&gt;   public static void main(String args[])&lt;br /&gt;   {&lt;br /&gt;      System.out.println("Hello World!");&lt;br /&gt;   }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;The usage is really simple. In addition all required CSS an JavaScript files are available online so you can refer them from your blogger page! Can't wait to submit some more code ;)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;&lt;span style="font-weight:bold;"&gt;Quick Note:&lt;/span&gt;&lt;/span&gt; When using this on blogger you'll need to turn the bloggerMode on. You can do it in JS:&lt;pre class="brush: js"&gt;SyntaxHighlighter.config.bloggerMode = true;&lt;/pre&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-4731178553113681354?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/4731178553113681354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=4731178553113681354' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/4731178553113681354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/4731178553113681354'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/03/code-snippets-on-blogger.html' title='Code snippets on blogger'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-2823611434060551914</id><published>2009-03-01T06:38:00.000-08:00</published><updated>2009-06-13T01:10:11.958-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>PHP: Redirection fails after moving to new server</title><content type='html'>Recently one of my old php apps was moved to different server.&lt;br /&gt;After the move it came out that some pages didn't work as expected i.e. some redirections were failing. The redirections were implemented using &lt;a href="http://php.net/header" target="_blank"&gt;header&lt;/a&gt; function e.g.&lt;br /&gt;&lt;pre class="brush: php; gutter: false; toolbar: false;"&gt;header('Location: http://www.targetpage.com/');&lt;/pre&gt;&lt;br /&gt;When I checked the php logs I found common error "&lt;span style="font-style:italic;"&gt;Headers already sent&lt;/span&gt;". Don't want to explain here what does it mean - there's plenty of answers &lt;a href="http://www.google.com/search?q=%22headers+already+sent%22" target="_blank"&gt;here&lt;/a&gt; ;) The only thing that made me wonder was why it was working on the old server. When I compared the php.ini files from both servers I found out that the new one was configured not to useoutput buffering. The temporary fix was enabling this by setting in php.ini:&lt;br /&gt;&lt;pre class="brush: bash; gutter: false;  toolbar: false;"&gt;output_buffer=On&lt;/pre&gt;&lt;br /&gt;This is not the cleanest solution and may affect application's performance but works immediately. The long-term solution is to ensure that your app is not sending any output before calling the &lt;code&gt;header&lt;/code&gt; method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-2823611434060551914?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/2823611434060551914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=2823611434060551914' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/2823611434060551914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/2823611434060551914'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/03/php-redirection-outputbuffer-z-phpini.html' title='PHP: Redirection fails after moving to new server'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-8626312227807808857</id><published>2009-02-20T02:55:00.000-08:00</published><updated>2009-06-13T01:12:02.658-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>MsBuild: How to copy/delete all files from subfolders</title><content type='html'>Copying entire folder content (with subfolders) using standard MsBuild is not as straightforward as I'd imagine this to be. The only solution I've found uses recursion. Following example &lt;b&gt;copies&lt;/b&gt; all files from &lt;code&gt;source&lt;/code&gt; to &lt;code&gt;dest&lt;/code&gt; folder:&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&lt;PropertyGroup&gt;&lt;br /&gt;  &lt;SourceDir&gt;C:\source&lt;/SourceDir&gt;&lt;br /&gt;  &lt;DestinationDir&gt;C:\dest&lt;/DestinationDir&gt;&lt;br /&gt;&lt;/PropertyGroup&gt;&lt;br /&gt;&lt;ItemGroup&gt;&lt;br /&gt;  &amp;lt;AllFolderFiles Include="$(SourceDir)\**\*.*" /&gt;&lt;br /&gt;&lt;/ItemGroup&gt;&lt;br /&gt;&amp;lt;Copy SourceFiles="@(AllFolderFiles)"&lt;br /&gt;  DestinationFiles="@(AllFolderFiles -&gt; $(DestinationDir)\&lt;br /&gt;  %(RecursiveDir)%(Filename)%(Extension)')" /&gt;&lt;/pre&gt;&lt;br /&gt;You can also use recursion to &lt;b&gt;delete&lt;/b&gt; all files in folder and its subfolders:&lt;pre class="brush: xml;"&gt;&lt;PropertyGroup&gt;&lt;br /&gt;  &lt;ToDelete&gt;C:\source&lt;/ToDelete&gt;&lt;br /&gt;&lt;/PropertyGroup&gt;&lt;br /&gt;&lt;ItemGroup&gt;&lt;br /&gt;  &amp;lt;FilesToDelete Include="$(ToDelete)\**\*.*" /&amp;gt;&lt;br /&gt;&lt;/ItemGroup&gt;&lt;br /&gt;&amp;lt;Delete Files="@(FilesToDelete)" /&amp;gt;&lt;/pre&gt;&lt;br /&gt;Anybody knows easier solution?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-8626312227807808857?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/8626312227807808857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=8626312227807808857' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8626312227807808857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/8626312227807808857'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/02/msbuild-how-to-copydelete-all-files.html' title='MsBuild: How to copy/delete all files from subfolders'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-2356325354793282406</id><published>2009-02-19T05:00:00.001-08:00</published><updated>2009-06-06T08:25:17.343-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Automatic webapp to IIS deployment using MsBuild</title><content type='html'>Sometimes, when buidling/deploying your projects standard &lt;a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" target="_blank"&gt;MsBuild&lt;/a&gt; tasks are not enough. I've found a very handy &lt;a href="http://www.codeplex.com/sdctasks" target="_blank"&gt;SDC tasks library&lt;/a&gt; which allows you to do much more from your build script. &lt;br /&gt;&lt;br /&gt;The following example demonstrates creation of application pool and website using this AppPool on IIS. Normally this would need to be done manually. Thanks to SDC we can automate the whole process to eliminate possible errors that can occure during manual deployment.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&amp;lt;!-- Use SDC tasks --&amp;gt;&lt;br /&gt;&amp;lt;UsingTask AssemblyFile="Microsoft.Sdc.Tasks.dll" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- Define website folder --&amp;gt;&lt;br /&gt;&amp;lt;PropertyGroup&amp;gt;&lt;br /&gt;  &amp;lt;WebSiteDestDir&amp;gt;&lt;br /&gt;       C:\Inetpub\wwwroot_mywebsite&lt;br /&gt;  &amp;lt;/WebSiteDestDir&amp;gt;&lt;br /&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- Main task --&amp;gt;&lt;br /&gt;&amp;lt;Target Name="Deploy_Webapp"&amp;gt;&lt;br /&gt;  &amp;lt;CallTarget Targets="CleanIIS" /&amp;gt;&lt;br /&gt;  &amp;lt;CallTarget Targets="CreateWebSite" /&amp;gt;&lt;br /&gt;  &amp;lt;CallTarget Targets="CopyContent" /&amp;gt;&lt;br /&gt;&amp;lt;/Target&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- Clean IIS: remove existing AppPool and Website --&amp;gt;&lt;br /&gt;&amp;lt;Target Name="CleanIIS"&amp;gt;&lt;br /&gt;  &amp;lt;Web.WebSite.Delete Description="myWebapp" /&amp;gt;&lt;br /&gt;  &amp;lt;Web.AppPool.Delete AppPoolName="myAppPool" /&amp;gt;&lt;br /&gt;&amp;lt;/Target&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- Create application pool --&amp;gt;&lt;br /&gt;&amp;lt;Target Name="CreateAppPool" &amp;gt;&lt;br /&gt;  &amp;lt;Message Text="Creating my AppPool" /&amp;gt;&lt;br /&gt;  &amp;lt;Web.AppPool.Create AppPoolName="myAppPool"&lt;br /&gt;                      WorkerProcesses="1"&lt;br /&gt;                      IdentityType="NetworkService"&lt;br /&gt;                      ContinueOnError="false"/&amp;gt;&lt;br /&gt;&amp;lt;/Target&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- Create website --&amp;gt;&lt;br /&gt;&amp;lt;Target Name="CreateWebSite" DependsOnTargets="CreateAppPool"&amp;gt;&lt;br /&gt;  &amp;lt;Message Text="Creating WebSite" /&amp;gt;&lt;br /&gt;  &amp;lt;Web.WebSite.Create Description="myWebapp"&lt;br /&gt;                      Path="$(WebSiteDestDir)"&lt;br /&gt;                      HostName="myWebapp"&lt;br /&gt;                      AppPoolId="myAppPool"&lt;br /&gt;                      ContinueOnError="false" /&amp;gt;&lt;br /&gt;&amp;lt;/Target&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;Target Name="CopyContent" DependsOnTargets="CreateWebSite"&amp;gt;&lt;br /&gt;  &amp;lt;!-- Copy the app content to WebSiteDestDir here --&amp;gt;&lt;br /&gt;&amp;lt;/Target&amp;gt;&lt;/pre&gt;Using this library you can also create ActiveDirectory user, virtual directories and a whole lot more!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-2356325354793282406?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/2356325354793282406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=2356325354793282406' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/2356325354793282406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/2356325354793282406'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/02/automatic-deployment-of-webapp-on-iis.html' title='Automatic webapp to IIS deployment using MsBuild'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-7871135681263341665</id><published>2009-02-11T13:44:00.000-08:00</published><updated>2009-02-12T01:24:34.805-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>Losing session data on IIS</title><content type='html'>I had a problem with asp.net app losing session data. The same app was working like a charm on my local machine but after deploying to dev server it was throwing exceptions from time to time caused by missing session variables.&lt;br /&gt; &lt;br /&gt;My webapp was using default sessionState settings with mode set to 'InProc' and it was configured to use default &lt;a href="http://www.developer.com/net/asp/article.php/2245511" target="_blank"&gt;application pool&lt;/a&gt;. The problem was caused by the application pool using Web Garden with 5 worker processes. When using InProc mode the worker processes DO NOT share session data! &lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;2 possible solutions:&lt;/span&gt;&lt;ol&gt;&lt;li&gt;Configure application pool to use 1 worker process: in IIS Manager right click yout application pool &gt; Properties &gt; Performance &gt; Web Garden section&lt;/li&gt;&lt;li&gt;Use different session state mode e.g. state server or sql server (set in web.config)&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-7871135681263341665?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/7871135681263341665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=7871135681263341665' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7871135681263341665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7871135681263341665'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/02/losing-session-data-on-iis.html' title='Losing session data on IIS'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-5700336041989974340</id><published>2009-02-10T03:06:00.001-08:00</published><updated>2009-06-06T08:28:52.148-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>Defining IBatis connection string in web.config</title><content type='html'>If you are using &lt;a href="ibatis.apache.org" target="_blank"&gt;Ibatis&lt;/a&gt; you may want to move the connection string from the &lt;code&gt;SqlMap.config&lt;/code&gt; file to the &lt;code&gt;Web.config&lt;/code&gt; e.g. to enable its encryption (see &lt;a href="http://fczaja.blogspot.com/2009/02/encrypt-configuration-sections.html"&gt;previous post&lt;/a&gt;). &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;Define your database connection in SqlMap.config as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: xml; "&gt;&amp;lt;database&amp;gt;&lt;br /&gt;  &amp;lt;provider name="sqlServer2.0"/&amp;gt;&lt;br /&gt;  &amp;lt;dataSource name="DB" connectionString="${dbConnStr}"/&amp;gt;&lt;br /&gt;&amp;lt;/database&amp;gt;&lt;/pre&gt;&lt;br /&gt;Define connection string in Web.config:&lt;pre class="brush: xml;"&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;  ...&lt;br /&gt;  &amp;lt;connectionStrings&amp;gt;&lt;br /&gt;    &amp;lt;add name="dbConnStr" connectionString="some conn str"/&amp;gt;&lt;br /&gt;  &amp;lt;/connectionStrings&amp;gt;&lt;br /&gt;  ...&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/pre&gt;&lt;br /&gt;Then, manually configure the builder when initializing the mapper:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Create builder&lt;br /&gt;DomSqlMapBuilder builder = new DomSqlMapBuilder();&lt;br /&gt;&lt;br /&gt;// Get connection string from web.config&lt;br /&gt;ConnectionStringSettings dbConnStr = &lt;br /&gt;                ConfigurationManager.ConnectionStrings["dbConnStr"];&lt;br /&gt;&lt;br /&gt;// Set dbConnStr property to &lt;br /&gt;// populate in sqlmap.config&lt;br /&gt;NameValueCollection properties = new NameValueCollection();&lt;br /&gt;properties.Add("dbConnStr", dbConnStr.ConnectionString);&lt;br /&gt;builder.Properties = properties;    &lt;br /&gt;&lt;br /&gt;// Create mapper&lt;br /&gt;ISqlMapper mapper = builder.Configure("SqlMap.config");&lt;/pre&gt;IBatis framework is quite handy in use but the documentation is very poor. For more advanced questions you'll need to digg through fora and blogs. I've found this tip &lt;a href="http://stackoverflow.com/questions/390595/best-way-to-retrieve-the-connection-string-for-ibatis-net-from-the-web-config" target="_blank"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-5700336041989974340?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/5700336041989974340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=5700336041989974340' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/5700336041989974340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/5700336041989974340'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/02/defining-ibatis-connection-string-in.html' title='Defining IBatis connection string in web.config'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-5301610798157318002</id><published>2009-02-09T00:42:00.001-08:00</published><updated>2009-06-06T15:50:55.350-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>Encrypting sections in web.config</title><content type='html'>Sometimes you want to ensure that your settings (e.g. connection strings) in web.config file are encrypted so nobody except the  app iteslf can read/understand them. ASP.Net offers tool called &lt;a href="http://msdn.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx" target="_blank"&gt;aspnet_regiis&lt;/a&gt; which allows that. It can be found in the &lt;code&gt;%WINDOWSDIR%\Microsoft.Net\Framework\version&lt;/code&gt; directory.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;Let's say we have a web app deployed on IIS called 'MyApp'. The app uses connection string defined in web.config:&lt;pre class="brush: xml;"&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;  ...&lt;br /&gt;  &amp;lt;connectionStrings&amp;gt;&lt;br /&gt;    &amp;lt;add name="myConnectionString" &lt;br /&gt;         connectionString="some connection string"/&amp;gt;&lt;br /&gt;  &amp;lt;/connectionStrings&amp;gt;&lt;br /&gt;  ...&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/pre&gt;&lt;br /&gt;The easiest way to encrypt presented connection string is to invoke following command:&lt;pre class="brush: bash; gutter: false; toolbar: false"&gt;aspnet_regiis&lt;br /&gt;  -pe "connectionStrings" -app "/MyApp"&lt;/pre&gt;&lt;br /&gt;It is also possible to encrypt web.config providing physical path to the application folder rather than app name (e.g. if app is not deployed on IIS):&lt;br /&gt;&lt;pre  class="brush: bash; gutter: false; toolbar: false"&gt;aspnet_regiis &lt;br /&gt;-pef "connectionStrings"&lt;br /&gt;"physical path to app root folder"&lt;/pre&gt;&lt;br /&gt;The encrypted information in the web.config can still be accessed by your app without any explicit decoding. Aspnet_regiis tool can be also used to descrypt information, encrypt different sections etc. You can learn more about it &lt;a href="http://msdn.microsoft.com/en-us/library/ms998280.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Warning&lt;/span&gt;&lt;br /&gt;If the encoding succeeds but tha app cannot read the encrypted section because of following error: &lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold"&gt;"Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;you have to add following parameter to your encryption command:&lt;pre  class="brush: bash; gutter: false; toolbar: false"&gt;aspnet_regiis &lt;br /&gt;  -pe "connectionStrings" -app "/MyApp"&lt;br /&gt;  -prov DataProtectionConfigurationProvider&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-5301610798157318002?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/5301610798157318002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=5301610798157318002' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/5301610798157318002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/5301610798157318002'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/02/encrypt-configuration-sections.html' title='Encrypting sections in web.config'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-4136671941235217794</id><published>2009-02-05T07:09:00.000-08:00</published><updated>2009-06-06T15:52:24.527-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>Adding tooltips to list items in DropDownList</title><content type='html'>I needed to add tooltips to the items on the standard &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.dropdownlist.aspx" target="_blank"&gt;DropDownList&lt;/a&gt; asp control. I'm using custom data source to retrieve the list of items rather than static list defined in html.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;Add a &lt;code&gt;ondatabound&lt;/code&gt; event handler to your DropDownList control:&lt;br /&gt;&lt;pre  class="brush: xml; highlight: [5]"&gt;&amp;lt;asp:DropDownList runat="server"&lt;br /&gt;                  DataSourceId="MyCustomDatasource"&lt;br /&gt;                  DataTextField="SomeName"&lt;br /&gt;                  DataValueField="SomeValueCode"&lt;br /&gt;                  ondatabound="ApplyOptionTitles"&lt;br /&gt;... /&amp;gt;&lt;/pre&gt;Then implement handler:&lt;pre  class="brush: csharp; gutter: false; toolbar: false;"&gt;protected void ApplyOptionTitles(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;   DropDownList ddl = sender as DropDownList;&lt;br /&gt;   if (ddl != null)&lt;br /&gt;   {&lt;br /&gt;        foreach (ListItem item in ddl.Items)&lt;br /&gt;        {&lt;br /&gt;           item.Attributes["title"] = item.Text;&lt;br /&gt;         }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;Answer found &lt;a href="http://forums.asp.net/p/903935/994720.aspx"  target="_blank"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-4136671941235217794?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/4136671941235217794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=4136671941235217794' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/4136671941235217794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/4136671941235217794'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/02/adding-tooltips-to-list-items-in.html' title='Adding tooltips to list items in DropDownList'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-675371181662149011</id><published>2009-02-04T23:18:00.000-08:00</published><updated>2009-06-13T01:28:09.692-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='ajax'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>Handling exceptions in UpdatePanel &amp; UpdatePanelAnimationExtender</title><content type='html'>&lt;a href="http://www.asp.net/ajax/ajaxcontroltoolkit/samples/UpdatePanelAnimation/UpdatePanelAnimation.aspx" target="_blank"&gt;UpdatePanelAnimationExtender&lt;/a&gt; allows you to add eye-catching animations to your UpdatePanel indicating that update is in progress. However, it doesn't directly support error handling. &lt;br /&gt;&lt;br /&gt;The following code defines UpdatePanelAnimationExtender for UpdatePanel MyUP. The panel will fade out each time the update starts and fade in after successful update.&lt;pre class="brush: xml;"&gt;&amp;lt;cc1:UpdatePanelAnimationExtender&lt;br /&gt;   ID="MyUPAE"&lt;br /&gt;   BehaviorID="UpdateAnimation"&lt;br /&gt;   runat="server"&lt;br /&gt;   Enabled="True"&lt;br /&gt;   TargetControlID="MyUP"&amp;gt;&lt;br /&gt;     &amp;lt;Animations &amp;gt;        &lt;br /&gt;        &amp;lt;OnUpdating &amp;gt;&lt;br /&gt;            &amp;lt;Parallel duration="0"&amp;gt;&lt;br /&gt;                &amp;lt;FadeOut minimumOpacity=".5" /&amp;gt;&lt;br /&gt;            &amp;lt;/Parallel&amp;gt;                &lt;br /&gt;        &amp;lt;/OnUpdating&amp;gt;&lt;br /&gt;        &amp;lt;OnUpdated&amp;gt;&lt;br /&gt;            &amp;lt;Parallel duration="0"&amp;gt;&lt;br /&gt;                &amp;lt;FadeIn minimumOpacity=".5" /&amp;gt;&lt;br /&gt;            &amp;lt;/Parallel&amp;gt; &lt;br /&gt;        &amp;lt;/OnUpdated&amp;gt;                        &lt;br /&gt;     &amp;lt;/Animations&amp;gt;&lt;br /&gt;&amp;lt;/cc1:UpdatePanelAnimationExtender&amp;gt;&lt;br /&gt;&lt;/cc1:UpdatePanelAnimationExtender&gt;&lt;/pre&gt;If the code executed during update causes an error the browser may warn you about JS error (caused by actual server side error) but the panel will remain faded out. Browser's warning is usually hard to notice or even not displayed at all. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;The following JS code allows you handling update errors on client side. It assumes that there is a &lt;code&gt;span&lt;/code&gt; element defined on that page for displaying error messages (with &lt;code&gt;ID=ErrorMsg&lt;/code&gt;).&lt;br /&gt;&lt;pre class="brush: js;"&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;&lt;br /&gt;// Create EndRequest handler for update panel&lt;br /&gt;Sys.WebForms.PageRequestManager.getInstance().&lt;br /&gt;                                    add_endRequest(EndRequestHandler);&lt;br /&gt;&lt;br /&gt;function EndRequestHandler(sender, args)&lt;br /&gt;{&lt;br /&gt;   // If there is an unhandled error&lt;br /&gt;  if (args.get_error() != undefined)&lt;br /&gt;  {&lt;br /&gt;    // create error message and display it&lt;br /&gt;    var errorLbl = $get('&lt;%=ErrorMsg.ClientID%&gt;');&lt;br /&gt;    errorLbl.innerHTML = 'An error occurred while completing update.';&lt;br /&gt;            &lt;br /&gt;    // end update panel animation&lt;br /&gt;    var upAnimation = $find('UpdateAnimation');&lt;br /&gt;    upAnimation._postBackPending = false;&lt;br /&gt;    upAnimation.get_OnUpdatingBehavior().quit();&lt;br /&gt;    upAnimation.get_OnUpdatedBehavior().play();&lt;br /&gt;                  &lt;br /&gt;    args.set_errorHandled(true);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-675371181662149011?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/675371181662149011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=675371181662149011' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/675371181662149011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/675371181662149011'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/02/handle-exception-in-updatepanel.html' title='Handling exceptions in UpdatePanel &amp; UpdatePanelAnimationExtender'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-7472665825549556286</id><published>2009-02-02T07:33:00.000-08:00</published><updated>2009-06-13T01:30:21.189-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>"Maximum request length exceeded" error</title><content type='html'>I have an aspx page using standard &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx" target="_blank"&gt;FileUpload&lt;/a&gt; control. When I tried to upload a file bigger than 4MB the page was not displayed or the following error message appeared: "&lt;span style="font-style:italic;"&gt;Maximum request length exceeded&lt;/span&gt;". This is caused by maximal allowed size of request accepted by the server. Since the uploaded file is sent in request's body the whole request is even bigger than the file itself. &lt;br /&gt;&lt;br /&gt;I've seen some solutions using &lt;code&gt;Application_Error&lt;/code&gt; handler defined in Global.asax. This approach is quite straightforward and seems to be a way to go but unfortunately it didn't work for me - the page was still not displayed and the error was not handled.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;First, set the size of request accepted by the server to maximum (1GB) in web.config. Then, define a custom &lt;a href="http://msdn.microsoft.com/en-us/library/aa719858(VS.71).aspx" target="_blank"&gt;HttpModule&lt;/a&gt; that would check request's length (also in web.config):&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&amp;lt;system.web&amp;gt;&lt;br /&gt;  &amp;lt;httpRuntime maxRequestLength="102400" /&amp;gt;&lt;br /&gt;  &amp;lt;httpModules&amp;gt;&lt;br /&gt;    &amp;lt;add name="RequestLengthCheck" &lt;br /&gt;         type="MyNamespace.RequestCheckModule, MyLibraryName" /&amp;gt;    &lt;br /&gt;    &amp;lt;/httpModules&amp;gt;    &lt;br /&gt;&amp;lt;/system.web&amp;gt;&lt;/pre&gt;Now you have to implement the HttpModule that would check request's size and redirect to an error page if it's too big:&lt;pre class="brush: csharp;"&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Web;&lt;br /&gt;&lt;br /&gt;namespace MyNamespace&lt;br /&gt;{&lt;br /&gt;  public class RequestCheckModule : IHttpModule&lt;br /&gt;  {&lt;br /&gt;    public void Init(HttpApplication app)&lt;br /&gt;    {&lt;br /&gt;      app.BeginRequest += new EventHandler(app_BeginRequest);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    void app_BeginRequest(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;      HttpContext context = (HttpApplication)sender).Context;&lt;br /&gt;&lt;br /&gt;      if (context.Request.ContentLength &gt; 4096000)&lt;br /&gt;      {&lt;br /&gt;      IServiceProvider prov = (IServiceProvider)context;&lt;br /&gt;      HttpWorkerRequest wr = &lt;br /&gt;          (HttpWorkerRequest)prov.GetService(typeof(HttpWorkerRequest));&lt;br /&gt;&lt;br /&gt;      // Check if body contains data&lt;br /&gt;      if (wr.HasEntityBody())&lt;br /&gt;      {&lt;br /&gt;        // get the total body length&lt;br /&gt;        int reqLength = wr.GetTotalEntityBodyLength();&lt;br /&gt;        // Get the initial bytes loaded&lt;br /&gt;        int initBytes = wr.GetPreloadedEntityBody().Length;&lt;br /&gt;          &lt;br /&gt;        if (!wr.IsEntireEntityBodyIsPreloaded())&lt;br /&gt;        {&lt;br /&gt;          byte[] buffer = new byte[512000];&lt;br /&gt;          // Set the received bytes to initial&lt;br /&gt;          // byted before start reading&lt;br /&gt;          int recBytes = initialBytes;&lt;br /&gt;          while (reqLength - recBytes &gt;= initBytes)&lt;br /&gt;          {&lt;br /&gt;            // Read another set of bytes&lt;br /&gt;            initBytes = wr.ReadEntityBody(buffer, buffer.Length);&lt;br /&gt;            // Update the received bytes&lt;br /&gt;            recBytes += initBytes;&lt;br /&gt;          }&lt;br /&gt;          wr.ReadEntityBody(buffer, reqLength-recBytes);&lt;br /&gt;          }&lt;br /&gt;        }&lt;br /&gt;        // Redirect the user to an error page.&lt;br /&gt;        context.Response.Redirect("Error.aspx");&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;        &lt;br /&gt;    public void Dispose()&lt;br /&gt;    {&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;I've found this piece of code &lt;a href="http://dotnetslackers.com/Community/blogs/haissam/archive/2008/09/25/redirect-to-error-page-when-maximum-request-length-is-exceeded-fileupload.aspx" target="_blank"&gt;here&lt;/a&gt;. It works perfect. The only thing I don't understand is why the whole request needs to be read for this to work? I've tried to make the redirection right after &lt;code&gt;wr.GetTotalEntityBodyLength();&lt;/code&gt; but it didn't work. Anybody knows why?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-7472665825549556286?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/7472665825549556286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=7472665825549556286' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7472665825549556286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/7472665825549556286'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/02/maximum-request-length-exceeded-error.html' title='&quot;Maximum request length exceeded&quot; error'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-4875560610981857501</id><published>2009-02-02T02:45:00.000-08:00</published><updated>2009-06-06T16:03:09.107-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Disable all page elements with transparent div</title><content type='html'>Sometimes you want to disable all page elements at one time. There are many ways to achieve that. I'm using an additional div displayed on the top layer of the page. It covers the whole page content and makes clicking elements on lower layers impossible. The div can be totally transparent so the user still sees the content of the lower layers.&lt;br /&gt;&lt;br /&gt;First, you need to place the additional div on your page, right behind the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tag:&lt;pre class="brush: xml;"&gt;...&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;   &amp;lt;div id="disablingDiv" &amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;Then, you need to create appropriate style for that div. This element needs to be displayed on the top layer:&lt;pre class="brush: css;"&gt;&lt;br /&gt;#disablingDiv&lt;br /&gt;{&lt;br /&gt;    /* Do not display it on entry */&lt;br /&gt;    display: none; &lt;br /&gt;&lt;br /&gt;    /* Display it on the layer with index 1001.&lt;br /&gt;       Make sure this is the highest z-index value&lt;br /&gt;       used by layers on that page */&lt;br /&gt;    z-index:1001;&lt;br /&gt;    &lt;br /&gt;    /* make it cover the whole screen */&lt;br /&gt;    position: absolute; &lt;br /&gt;    top: 0%; &lt;br /&gt;    left: 0%; &lt;br /&gt;    width: 100%; &lt;br /&gt;    height: 100%; &lt;br /&gt;&lt;br /&gt;    /* make it white but fully transparent */&lt;br /&gt;    background-color: white; &lt;br /&gt;    opacity:.00; &lt;br /&gt;    filter: alpha(opacity=00); &lt;br /&gt;}&lt;/pre&gt;Now it is ready to use but not displayed. If you want to enable the div (to disable all underlaying page elements) just invoke the following JS code:&lt;pre class="brush: js;"&gt;&lt;br /&gt;document.getElementById('disablingDiv').style.display='block';&lt;br /&gt;&lt;/pre&gt;To disable it again:&lt;pre class="brush: js;"&gt;   document.getElementById('disablingDiv').style.display='none';&lt;br /&gt;&lt;/pre&gt;You can also play with background color and opacity to create different effects. The div itself can contain some additional elements e.g. button allowing enabling, pictures, etc. &lt;br /&gt;I've created this simple style basing on more complex example of lightbox described &lt;a href="http://www.ivirtuaforums.com/screw-javascript-use-css-to-create-a-lightbox-effect-t10777" target="_blank"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-4875560610981857501?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/4875560610981857501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=4875560610981857501' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/4875560610981857501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/4875560610981857501'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/02/disable-all-page-elements-with.html' title='Disable all page elements with transparent div'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-293515889459171301</id><published>2009-01-29T12:22:00.000-08:00</published><updated>2009-01-29T12:32:04.078-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Free Java training courses</title><content type='html'>At &lt;a href="http://www.sun.com/training/glassfish_login.html" target="_blank"&gt;http://www.sun.com/training/glassfish_login.html&lt;/a&gt; you can find 6 free 90-days trial courses on follwiong topics:&lt;ol&gt;&lt;br /&gt;&lt;li&gt;GlassFish Application Server: Introduction (WMT-SAS-1536)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Designing Java Web Services (WJ-4112-EE5)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Adding Quality of Service and .NET Interoperability to Web Services (WMT-SAS-1543)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Creating Reliable and Secure Interoperable Web Services (WMT-SAS-2544)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Creating Transactional Web Services (WMT-SAS-2545)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Working With the Web Services Policy (WMT-SAS-2546)&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;Sounds interesting to me - you better check that out before the promotion ends!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-293515889459171301?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/293515889459171301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=293515889459171301' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/293515889459171301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/293515889459171301'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/01/free-java-training-courses.html' title='Free Java training courses'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7041745156199549192.post-2994736228221711874</id><published>2009-01-22T08:14:00.000-08:00</published><updated>2009-06-07T01:10:19.596-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>DropDownList with OptGroup support</title><content type='html'>Strangely guys from Microsoft did not implement (forgot???) support for &lt;code&gt;optgroup&lt;/code&gt; tag in their standard DropDownList asp control so it's not possible to group items on the list. &lt;br /&gt;&lt;br /&gt;Most of the workarounds found in Web suggest use of Control Adapter, like &lt;a href="http://www.codeproject.com/KB/custom-controls/DropDownListOptionGroup.aspx" target="_blank"&gt;this one&lt;/a&gt;. However, there are couple things I don't like in this solution:&lt;ul&gt;&lt;li&gt;Doesn't work correctly when DataSource, AutoPostBack or OnSelectedIndexChanged attributes are set&lt;/li&gt;&lt;li&gt;Overrides regular regular behaviour &amp; rendering of DropDownList items&lt;/li&gt;&lt;li&gt;Works for all DropDownList controls on the page (cannot be switched off for some lists)&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;Instead, I propose to create our own custom control that extends the standard DropDownList class. We need to override the method RenderContents inherited by DropDownList from &lt;code&gt;System.Web.UI.WebControls.ListControl&lt;/code&gt;. When overriding it is very useful to base on original implementation so the default behaviour is preserved. To get the original RenderContents method's code you can use &lt;a href="http://www.red-gate.com/products/reflector/" target="_blank"&gt;.NET Reflector&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7so4C0dWMLE/SZV9bNFKCNI/AAAAAAAAAE8/shC6q2yzhC4/s1600-h/reflector.bmp"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 326px;" src="http://2.bp.blogspot.com/_7so4C0dWMLE/SZV9bNFKCNI/AAAAAAAAAE8/shC6q2yzhC4/s400/reflector.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5302282042619857106" /&gt;&lt;/a&gt;&lt;br /&gt;So, your custom list control needs to look as follows:&lt;pre class="brush: csharp;"&gt;namespace MyNamespace&lt;br /&gt;{&lt;br /&gt;  public class MyList : System.Web.UI.WebControls.DropDownList&lt;br /&gt;  {&lt;br /&gt;    protected override void RenderContents(&lt;br /&gt;                            System.Web.UI.HtmlTextWriter writer)&lt;br /&gt;    {&lt;br /&gt;      // Custom implementation goes here        &lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;Once you create your custom DropDownList you can use it on a page just like any other control. You only need to register it explicitly using following directive:&lt;pre class="brush: xml;"&gt;&amp;lt;%@ Register assembly="MyAssembly"&lt;br /&gt;             namespace="MyNamespace"&lt;br /&gt;             tagprefix="ma" %&amp;gt;&lt;br /&gt;...&lt;br /&gt;&amp;lt;ma:MyList ... /&amp;gt;&lt;/pre&gt;&lt;br /&gt;Advantages of this appraoch:&lt;ul&gt;&lt;li&gt;Original behaviour is preserved.&lt;/li&gt;&lt;li&gt;You can use custom control only if you need grouping without affecting the rest of drop-downs on page&lt;/li&gt;&lt;li&gt;You can implement several custom drop downs with different customizations&lt;/li&gt;&lt;li&gt;Should work with AutoPostBack &amp; OnSelectedIndexChanged&lt;/li&gt;&lt;/ul&gt;I've found sample implementation using this approach &lt;a href="http://www.norimek.com/blog/post/2008/06/Implementing-OptGroup-In-A-DropDownList-Control.aspx" target="_blank"&gt;here&lt;/a&gt; and &lt;a href="http://www.norimek.com/blog/post/2008/06/Implementing-OptGroup-In-A-DropDownList-Control.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7041745156199549192-2994736228221711874?l=fczaja.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fczaja.blogspot.com/feeds/2994736228221711874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7041745156199549192&amp;postID=2994736228221711874' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/2994736228221711874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7041745156199549192/posts/default/2994736228221711874'/><link rel='alternate' type='text/html' href='http://fczaja.blogspot.com/2009/01/dropdownlist-with-optgroup-support.html' title='DropDownList with OptGroup support'/><author><name>Filip Czaja</name><uri>http://www.blogger.com/profile/12289949072596625867</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11057490579395461685'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7so4C0dWMLE/SZV9bNFKCNI/AAAAAAAAAE8/shC6q2yzhC4/s72-c/reflector.bmp' height='72' width='72'/><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry></feed>