<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://involvenevolve.com/rss/xslt"?>
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Sudarshan's Blog</title>
    <link>http://involvenevolve.com/</link>
    <description>My Thoughts, Findings &amp; Experiences</description>
    <generator>Articulate, blogging built on Umbraco</generator>
    <item>
      <guid isPermaLink="false">2113</guid>
      <link>http://involvenevolve.com/post/iis-75-binding-wild-card-certificate-issue/</link>
      <category>Asp.Net</category>
      <category>IIS</category>
      <title>IIS 7.5 &amp; Binding Wild Card Certificate Issue</title>
      <description>&lt;p&gt;Recently we were working on Asp.Net MVC project which was going to be deployed on IIS 7.5. So, we installed a wildcard certificate on the web server which we can use for other sites under the same domain.&lt;/p&gt;
&lt;p&gt;But, when we tried associating the certificate withHost Name then it was NOT working. IIS was not allowing to enter value inHost Name field even though we have selected correct certificate.&lt;/p&gt;
&lt;p&gt;&lt;img style="width: 407px; height:222px;" src="http://involvenevolve.com/media/1056/iis-site-bindings.png?width=407&amp;amp;height=222" alt="Host name textbox is disabled" data-id="3118"&gt;&lt;/p&gt;
&lt;p&gt;We found some articles about how to associate hostname using commands.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.sslshopper.com/article-ssl-host-headers-in-iis-7.html"&gt;https://www.sslshopper.com/article-ssl-host-headers-in-iis-7.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/16276860/iis-7-adding-ssl-to-one-site-all-other-sites-responds-to-https-request"&gt;http://stackoverflow.com/questions/16276860/iis-7-adding-ssl-to-one-site-all-other-sites-responds-to-https-request&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If we go via approach specified in these articles then it works ONLY if website has a binding&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;with port 443 without the hostname&lt;/li&gt;
&lt;li&gt;with port 443 with the hostname&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With this, you can't see the hostname is associated with a site when you try to edit the binding. BUT you can access a website using hostname just fine. Here is how IIS binding looks like&lt;/p&gt;
&lt;p&gt;&lt;img style="width: 751px; height: 236px;" src="http://involvenevolve.com/media/1058/website-bindings.png?width=751&amp;amp;height=236" alt="Both default and custom hostname bindings required" data-id="3120"&gt;&lt;/p&gt;
&lt;p&gt;Both default and custom hostname bindings required&lt;/p&gt;
&lt;p&gt;Now the drawback is: Even though you have wildcard certificate, you can't associate that to other websites on the IIS :(.&lt;/p&gt;
&lt;h6&gt;Real issue&lt;/h6&gt;
&lt;p&gt;Looks like IIS does not understand wild card certificate as wild card certificate unless it &lt;strong&gt;Friendly Name&lt;/strong&gt; starts with &lt;strong&gt;*.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In our case it's friendly name was &lt;em&gt;Wildcard certificate valid till XXXXX date&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So, you need to change the friendly name which will start with &lt;strong&gt;*.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To do this,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select Start –&amp;gt; Run&lt;/li&gt;
&lt;li&gt;Type in “MMC” and hit enter&lt;/li&gt;
&lt;li&gt;From the console, select File –&amp;gt; Add / Remove Snap-in&lt;/li&gt;
&lt;li&gt;Select Certificates from the Add / Remove dialog&lt;/li&gt;
&lt;li&gt;Select Computer Account when prompt for which certificates the snap-in will manage.&lt;/li&gt;
&lt;li&gt;Select Local Computer when prompted&lt;/li&gt;
&lt;li&gt;Click OK to add the Snap-in to the MMC&lt;/li&gt;
&lt;li&gt;Locate your SSL certificate&lt;/li&gt;
&lt;li&gt;Double click the certificate&lt;/li&gt;
&lt;li&gt;Select 'Details' tab and select 'Edit Properties'&lt;/li&gt;
&lt;li&gt;You should be able to change the friendly name.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img style="width: 400.3944773175543px; height:500px;" src="http://involvenevolve.com/media/1053/changed-friendly-name.png?width=400.3944773175543&amp;amp;height=500" alt="Change certificate friendly name" data-id="3115"&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Now, if you go back to IIS and try to add/edit bindings, you can now enterHost Name along with selecting wild card certificate&lt;/p&gt;
&lt;p&gt;&lt;img style="width: 408px; height:221px;" src="http://involvenevolve.com/media/1055/editable-host-name.png?width=408&amp;amp;height=221" alt="Hostname textbox is editbale in IIS" data-id="3117"&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Below article has good information about IIS and certificates:&lt;br&gt;&lt;a href="http://blogs.msdn.com/b/varunm/archive/2013/06/18/bind-multiple-sites-on-same-ip-address-and-port-in-ssl.aspx"&gt;http://blogs.msdn.com/b/varunm/archive/2013/06/18/bind-multiple-sites-on-same-ip-address-and-port-in-ssl.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now, you can also associate the same certificate with multiple websites on same IIS server!&lt;/p&gt;</description>
      <pubDate>Sat, 21 Feb 2015 21:32:25 Z</pubDate>
      <a10:updated>2015-02-21T21:32:25Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1102</guid>
      <link>http://involvenevolve.com/archive/aspnet-ajax-async-call-doesnt-fire-jquerys-documentready-event-solution/</link>
      <category>Asp.Net</category>
      <category>AJAX</category>
      <title>ASP.NET AJAX async call doesn't fire jQuery's 'document.ready()' event: Solution</title>
      <description>&lt;p&gt;On our current project we were using following technologies:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;ASP.NET&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;jQuery&lt;/strong&gt;: for DOM manipulation at client side&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;jQuery plugins&lt;/strong&gt; like validator plugin, cleditor plugin, msked input plugin etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ASP.NET AJAX&lt;/strong&gt;: For doing asynchronous calls&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Before introducing AJAX functionality on the page, all the jQuery plugins were working fine.But, as we implement AJAX functionality on the page, all the plugins stopped working.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;BIG QUESTION&lt;/strong&gt;, why?&lt;/p&gt;
&lt;p&gt;Lets examine working on any jQuery plugin. We need to perform some operations inside the jQuery's 'document.ready()' event.&lt;/p&gt;
&lt;p&gt;Here is the example for masked input plugin:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="font-size: 8pt; overflow: visible; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$(document).ready(&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;() {&lt;br /&gt;    &lt;span style="color: #008000;"&gt;// Attaches masks to page controls&lt;/span&gt;&lt;br /&gt;    $(&lt;span style="color: #006080;"&gt;'#&amp;lt;%= txtSsn.ClientID %&amp;gt;'&lt;/span&gt;).mask(&lt;span style="color: #006080;"&gt;"999-99-9999"&lt;/span&gt;);&lt;br /&gt;    $(&lt;span style="color: #006080;"&gt;'#&amp;lt;%= txtBirthDate.ClientID %&amp;gt;'&lt;/span&gt;).mask(&lt;span style="color: #006080;"&gt;"99-99-9999"&lt;/span&gt;);&lt;br /&gt;});&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This code get executed every time page is loaded.&lt;/p&gt;
&lt;p&gt;Now, when we do asynchronous call using ASP.NET AJAX, only update panel's content get refreshed and not the whole page. This is why jQuery's '&lt;strong&gt;document.ready()&lt;/strong&gt;' event doesn't get fired. Because of this the masking associated with page controls gets removed.&lt;/p&gt;
&lt;p&gt;But, this is so common situation and what to do?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;There are 2 different ways that I know:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Make use of async call end event which is provided by ASP.NET AJAX. I don't prefer this way because we need to explicitly register and handle async event.&lt;/li&gt;
&lt;li&gt;Implement jQuery '&lt;strong&gt;AjaxReady&lt;/strong&gt;' event . (&lt;em&gt;Thanks to unknown person who posted this solution on some forum, but he missed out to mention how exactly we should use it&lt;/em&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So, we will prefer 2nd way.&lt;/p&gt;
&lt;p&gt;This solutions involves following steps:&lt;/p&gt;
&lt;h4&gt;Register event into jQuery like this&lt;/h4&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="font-size: 8pt; overflow: visible; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;jQuery.fn.extend({&lt;br /&gt;    AjaxReady: &lt;span style="color: #0000ff;"&gt;function&lt;/span&gt; (fn) {&lt;br /&gt;        &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (fn) {&lt;br /&gt;            &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; jQuery.&lt;span style="color: #0000ff;"&gt;event&lt;/span&gt;.add(&lt;span style="color: #0000ff;"&gt;this&lt;/span&gt;[0], &lt;span style="color: #006080;"&gt;"AjaxReady"&lt;/span&gt;, fn, &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;);&lt;br /&gt;        } &lt;span style="color: #0000ff;"&gt;else&lt;/span&gt; {&lt;br /&gt;            &lt;span style="color: #0000ff;"&gt;var&lt;/span&gt; ret = jQuery.&lt;span style="color: #0000ff;"&gt;event&lt;/span&gt;.trigger(&lt;span style="color: #006080;"&gt;"AjaxReady"&lt;/span&gt;, &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;, &lt;span style="color: #0000ff;"&gt;this&lt;/span&gt;[0], &lt;span style="color: #0000ff;"&gt;false&lt;/span&gt;, &lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;);&lt;br /&gt;            &lt;span style="color: #008000;"&gt;// if there was no return value then the even validated correctly  &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; (ret === undefined)&lt;br /&gt;                ret = &lt;span style="color: #0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; ret;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;});&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This code should present into your &lt;strong&gt;*.js&lt;/strong&gt; file or inside '&lt;strong&gt;&amp;lt;script language="javascript"&amp;gt;&lt;/strong&gt;' tag&lt;/p&gt;
&lt;h4&gt;Add following script within update panel's 'ContentTemplate'&lt;/h4&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="font-size: 8pt; overflow: visible; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;lt;asp:UpdatePanel ID=&lt;span style="color: #006080;"&gt;"upnlInsuranceCarrier"&lt;/span&gt; runat=&lt;span style="color: #006080;"&gt;"server"&lt;/span&gt;&amp;gt;&lt;br /&gt;    &amp;lt;ContentTemplate&amp;gt;&lt;br /&gt;        &lt;span style="color: #008000;"&gt;// Below script is very important&lt;/span&gt;&lt;br /&gt;        &amp;lt;script type=&lt;span style="color: #006080;"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&lt;br /&gt;            prm = Sys.WebForms.PageRequestManager.getInstance();&lt;br /&gt;            prm.add_endRequest(EndRequest);&lt;br /&gt;            &lt;span style="color: #0000ff;"&gt;function&lt;/span&gt; EndRequest(sender, args) {&lt;br /&gt;                $(document).AjaxReady();&lt;br /&gt;            }&lt;br /&gt;        &amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h4&gt;Define your $(document).AjaxReady() event like this&lt;/h4&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="font-size: 8pt; overflow: visible; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$(document).AjaxReady(&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt; () {&lt;br /&gt;    &lt;span style="color: #008000;"&gt;// Add code which needs to be executed after async call&lt;/span&gt;&lt;br /&gt;});&lt;/pre&gt;
&lt;/div&gt;
&lt;h4&gt;Finally your code will look like&lt;/h4&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="font-size: 8pt; overflow: visible; font-family: 'Courier New', courier, monospace; width: 100%; color: black; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$(document).ready(&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt; () {&lt;br /&gt;    setup();&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;$(document).AjaxReady(&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt; () {&lt;br /&gt;    setup();&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt; setup() {&lt;br /&gt;    $(&lt;span style="color: #006080;"&gt;'#&amp;lt;%= txtSsn.ClientID %&amp;gt;'&lt;/span&gt;).mask(&lt;span style="color: #006080;"&gt;"999-99-9999"&lt;/span&gt;);&lt;br /&gt;    $(&lt;span style="color: #006080;"&gt;'#&amp;lt;%= txtBirthDate.ClientID %&amp;gt;'&lt;/span&gt;).mask(&lt;span style="color: #006080;"&gt;"99-99-9999"&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Now, masked input plugin will work fine &lt;span style="color: #0000ff;"&gt;in&lt;/span&gt; async call &lt;span style="color: #0000ff;"&gt;as&lt;/span&gt; well&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Happy Programming!&lt;/p&gt;</description>
      <pubDate>Wed, 06 Oct 2010 00:56:13 Z</pubDate>
      <a10:updated>2010-10-06T00:56:13Z</a10:updated>
    </item>
  </channel>
</rss>